I am trying to show notification in the app. App show notification when background or foreground But the App crash when app not clear from app background stack. I don't know why it happens. below is my app notification code Any Help will be Appreciated.
if (VERSION.SDK_INT >= 26) {
notif = (new android.app.Notification.Builder(this, this.getString(string.notification_channel_id))).setSmallIcon(notificationResId).setContentTitle(title).setStyle((new BigTextStyle()).bigText(this.mText == null ? "" : this.mText)).setContentText(this.mText == null ? "" : this.mText).setVisibility(0).setChannelId(this.getString(string.notification_channel_id)).setAutoCancel(true);
} else {
mBuilder = (new Builder(this)).setContentTitle(title).setSmallIcon(notificationResId).setStyle((new android.support.v4.app.NotificationCompat.BigTextStyle()).bigText(this.mText == null ? "" : this.mText)).setContentText(this.mText == null ? "" : this.mText).setAutoCancel(true).setDefaults(-1);
}
if (VERSION.SDK_INT >= 26) {
notif.setContentIntent(contentIntent);
this.mNotificationManager.notify(id, notif.build());
} else {
mBuilder.setContentIntent(contentIntent);
this.mNotificationManager.notify(id, mBuilder.build());
}
Error:
java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(pri=0 contentView=null vibrate=default sound=default defaults=0xffffffff flags=0x11 color=0x00000000 vis=PRIVATE semFlags=0x0 semPriority=0)