Sometimes my application get this kind of exception:
Fatal Exception: android.app.RemoteServiceException: Bad notification posted from package com.packagename: Couldn't expand RemoteViews for: StatusBarNotification(pkg=com.packagename user=UserHandle{0} id=136094146 tag=null score=0: Notification(pri=0 contentView=com.packagename/0x109007e vibrate=default sound=default defaults=0xffffffff flags=0x11 kind=[null]))
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(NativeStart.java)
Code creating notification:
PendingIntent intent = PendingIntent.getActivities(this, id,
notificationIntents, PendingIntent.FLAG_UPDATE_CURRENT);
int color = ContextCompat.getColor(this, R.color.notif_background);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setContentText(description)
.setSmallIcon(getSmallIcon())
.setLargeIcon(getLargeIcon())
.setColor(color)
.setDefaults(NotificationCompat.DEFAULT_ALL)
.setAutoCancel(true)
.setStyle(new NotificationCompat.BigPictureStyle().bigLargeIcon(largeIcon))
.setContentIntent(intent);
if (title != null) {
notificationBuilder.setContentTitle(title)
.setTicker(title)
.setStyle(new NotificationCompat.BigTextStyle()
.setBigContentTitle(title).bigText(description));
} else {
notificationBuilder.setStyle(new NotificationCompat.BigTextStyle()
.bigText(description));
}
if (image != null) {
notificationBuilder
.setStyle(new NotificationCompat.BigPictureStyle()
.bigPicture(image).setSummaryText(description));
}
android.app.Notification notification = notificationBuilder.build();
notificationManager.notify(id, notification);
I have seen almost all the solution on stack overflow and it shows that this issue is regarding custom layout. But I didn't use custom layout. I couldn't understand what is the exact issue. Can anyone help?