14

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?

3

5 Answers 5

34

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()) 
Sign up to request clarification or add additional context in comments.

3 Comments

Is it works on Android 8+ with its new notification channels system?
@KoenVanLooveren I've updated the post to include the required setting for Android 8+
No the icon does not hide on Android 8+. It is just added at the bottom of my notification stack.
3

.setPriority with parameter PRIORITY_MIN will make this possible.

NotificationCompat notification = new NotificationCompat.Builder(this) .setContentTitle(getString(R.string.app_name)) .setContentText(getString(R.string.notification_text)) .setSmallIcon(R.mipmap.ic_launcher) //Show the notification only in NotificationDrawer. //Notification will not be shown on LockScreen as well as Hidden Icon on StatusBar. .setPriority(Notification.PRIORITY_MIN) .build(); 

3 Comments

what's the from @Floern answer?
@VladMatvienko Mine is a complete code in case any new learner needs it.
It was not yesterday, until you've editted it 27 min. ago
1

NotificationManager.IMPORTANCE_UNSPECIFIED works in my case

1 Comment

Amazing! And it's better yet! Stays kind of hidden in the bottom and must be opened to show everything. Perfect. Thank you! Wasn't expecting this from "unspecified" xD.
-1

You can do this by having a total transparent image and use that as your icon. :)

1 Comment

Thanks but I don't want to take any space on the statusbar. Maybe there isn't a way...
-2

there is no way to show notification without icon.

You can use transparent image. But, it take space of icon. 

@CommonsWare: Since the primary point of raising a Notification is to put an icon in the status bar, there is usually no need to not put an icon in the status bar, unless it is interactive, such as a toggle or information notification that will always run and you might want on the pull down, but has no use for an icon.

check this answer for more detail.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.