मैं here (अनुभाग Creating a Custom Notification Layout) से Google के नमूने का उपयोग करके अपने एंड्रॉइड एप्लिकेशन में कस्टम नोटिफिकेशन का उपयोग करने का प्रयास कर रहा हूं। चूंकि मैं इस सटीक कोड का उपयोग कर रहा हूं, इसलिए मुझे RuntimeException
प्रत्येक अधिसूचना को निकाल दिया गया है।कस्टम अधिसूचना: java.lang.RuntimeException: खराब सरणी लंबाई
मेरे स्टैक ट्रेस:
FATAL EXCEPTION: main
java.lang.RuntimeException: bad array lengths
at android.os.Parcel.readIntArray(Parcel.java:677)
at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.java:369)
at android.app.NotificationManager.notify(NotificationManager.java:110)
at android.app.NotificationManager.notify(NotificationManager.java:90)
at com.****.service.UpdateFeedService.notifyUpdateProgress(UpdateFeedService.java:266)
at com.****.service.task.PodcastUpdaterTask.onProgressUpdate(PodcastUpdaterTask.java:63)
at com.****.service.task.PodcastUpdaterTask.onProgressUpdate(PodcastUpdaterTask.java:1)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:432)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:4937)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
मेरे कोड:
private final Intent updateInProgressIntent = new Intent(this.context, PodcastListActivity.class);
private RemoteViews updateInProgressContentView = null;
private PendingIntent updateInProgressPendingIntent = null;
private Notification updateInProgressNotification = null;
...
@Override
public void onCreate() {
super.onCreate();
...
this.updateInProgressPendingIntent = PendingIntent.getActivity(this, UPDATE_INPROGRESS_NOTIFICATION_ID,
this.updateInProgressIntent, PendingIntent.FLAG_UPDATE_CURRENT);
this.updateInProgressContentView = new RemoteViews(getPackageName(), R.layout.custom_notification);
...
}
public void notifyUpdateProgress(final int index, final int size, final Podcast podcast) {
this.updateInProgressContentView.setImageViewBitmap(
R.id.image, ActivityHelper.getBitmap(context, podcast.getThumbnailAsset()));
this.updateInProgressContentView.setTextViewText(R.id.title, "some msg");
this.updateInProgressContentView.setTextViewText(R.id.text, podcast.getName());
this.updateInProgressNotification.contentView = this.updateInProgressContentView;
this.updateInProgressNotification.contentIntent = this.updateInProgressPendingIntent;
this.notificationManager.notify(UPDATE_INPROGRESS_NOTIFICATION_ID, this.updateInProgressNotification);
...
}
अगर मैं एक मानक एक (setLatestEventInfo()
के साथ) के साथ कस्टम अधिसूचना की जगह मैं कोई समस्या नहीं।
कभी-कभी मुझे यह ब्रांड एक नया नया रिमोट व्यू के साथ भी मिलता है, इसलिए मुझे लगता है कि यह @ बिघेम – tokudu
@ ब्रिघम का उत्तर सही है, जैसा कि बिटमैप्स से संबंधित है। हो सकता है कि आप अपने 'रिमोट व्यू' के आस-पास 'बिटमैप' ऑब्जेक्ट्स लीक कर रहे हों। –