I'd like to know how to create a notification that doesn't show the icon in the statusbar.
There is a way to hide it?
Since Android 4.1 (API level 16) it's possible to specify a notification's priority
. If you set that flag to PRIORITY_MIN
the notification icon won't show up on the statusbar.
notification.priority = Notification.PRIORITY_MIN;
Or in case you use a Notification.Builder
:
builder.setPriority(Notification.PRIORITY_MIN);
As of Android 8.0 Oreo (API level 26) you have to set the importance
of the notification's NotificationChannel
to IMPORTANCE_MIN
:
NotificationChannel channel =
new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_MIN);
notificationManager.createNotificationChannel(channel);
...
builder.setChannelId(channel.getId())