Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Notification.Builder: show a notification without icon

 String ns = Context.NOTIFICATION_SERVICE;
 NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

 int icon = R.drawable.ic_notification_icon;
 android.app.Notification.Builder nbuilder = new Notification.Builder(this);

 nbuilder.setContentTitle(getString(R.string.notifcation_title,mProfile.mName));
 nbuilder.setContentText(msg);
 nbuilder.setOnlyAlertOnce(true);
 nbuilder.setOngoing(true);
 nbuilder.setSmallIcon(icon,level.level);

How can I hide or completely delete the smallIcon? I tried to not use nbuilder.setSmallIcon, but the result is that the notification is not shown at all!

like image 554
user1071138 Avatar asked Apr 23 '13 13:04

user1071138


People also ask

How do I hide icon notifications 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.

Can Android change notification icons?

Currently users can't change the notification icon, but I could make it possible to select one of the 300+ Automate icons. A custom picture isn't possible since Android requires the images to be packaged within the app.

How do I show app icon in notification?

Turn on App icon badges from Settings. Navigate back to the main Settings screen, tap Notifications, and then tap Advanced settings. Tap the switch next to App icon badges to turn them on.


1 Answers

On Jelly Bean and later you can use nbuilder.setPriority(Notification.PRIORITY_MIN); the exact interpretation of this priority level is left up to the system UI, but in AOSP this causes the notification's icon to be hidden.

This is intended for "ambient" or "background" information that doesn't need to get the user's attention, but if the user happens to be poking around the notification panel, she might be interested. See the Notifications section of the Android Design site for more about how to best use notification priority.

like image 99
dsandler Avatar answered Sep 20 '22 10:09

dsandler