Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a notification without icon in the statusbar or simply hide it?

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?

like image 296
Meroelyth Avatar asked Jul 07 '12 09:07

Meroelyth


People also ask

How do I remove icon from notification bar?

How do I hide the status bar on Android? With a stock Android phone, press and hold Settings until System Settings appears. Select System UI Tuner > Status Bar, and turn off all the options.

How do I get rid of notification icons on Android?

Once you're in the app settings, you'll notice the “Notifications” submenu. Open it. There you'll see a ton of notification options on a system level. You can basically choose to minimize status bar notifications for one particular type of notification.

How do I make a custom notification bar?

To customize it, first pull down the slider bar from the top of the screen. Next, tap on the three vertical dots in the top right corner. Now click on Status bar. You're in.


1 Answers

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())
like image 89
Floern Avatar answered Oct 11 '22 17:10

Floern