In my application i wrote simple notification function, the method shows icon only on status bar and i want to show notification layout too, but not shown automatically and i have pull down android status bar down to see that,
public static void createNotification(Context context, Class activity, String title, String subject, int count_unread_message) {
Intent intent = new Intent(context, activity);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, Intent.FLAG_ACTIVITY_NEW_TASK);
Notification notify = new NotificationCompat.Builder(context)
.setAutoCancel(true)
.setContentTitle(title)
.setContentText(subject)
.setSmallIcon(R.mipmap.ic_launcher)
.setNumber(count_unread_message)
.setPriority(0)
.setLights(Color.BLUE, 500, 500)
.setContentIntent(pendingIntent)
.build();
notify.flags |= Notification.FLAG_AUTO_CANCEL;
NOTIFICATIONMANAGER = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
NOTIFICATIONMANAGER.notify(159753456, notify);
}
It seems this problem is for android 6 and above
For me this was solved by calling setDefaults(Notification.DEFAULT_ALL)
on the builder. Hope that helps,
Paul
Add .setLargeIcon(R.mipmap.ic_launcher)
in your code
Bitmap icon = BitmapFactory.decodeResource(context.getResources(),
R.drawable.yourIcon);
Notification notify = new NotificationCompat.Builder(context)
.setAutoCancel(true)
.setContentTitle(title)
.setContentText(subject)
.setSmallIcon(R.mipmap.ic_launcher)
.setLargeIcon(icon)//can set only bitmap images convert your drawable to bitmap
.setNumber(count_unread_message)
.setPriority(0)
.setLights(Color.BLUE, 500, 500)
.setContentIntent(pendingIntent)
.build();
https://developer.android.com/reference/android/app/Notification.html#largeIcon
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With