Skip to content

Most visited

Recently visited


Modify a Notification Badge

Starting with 8.0 (API level 26), notification badges (also known as notification dots) appear on a launcher icon when the associated app has an active notification. Users can long-press on the app icon to reveal the notifications (alongside any app shortcuts), as shown in figure 1.

These dots appear by default in launcher apps that support them and there's nothing your app needs to do. However, there might be situations in which you don't want the to notification dot to appear or you want to control exactly which notifications to appear there.

Figure 5. Notification badges and the long-press menu

Disable badging

There are cases where badges don't make sense for your notifications, so you can disable them on a per-channel basis by calling setShowBadge(false) on your NotificationChannel object.

For example, you might want to disable notification badges in the following situations:

The following sample code illustrates how to hide badges for a notification channel:

String id = "my_channel_01";
CharSequence name = getString(R.string.channel_name);
String description = getString(R.string.channel_description);
int importance = NotificationManager.IMPORTANCE_LOW;
NotificationChannel mChannel = new NotificationChannel(id, name, importance);

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

Set custom notification count

By default, each notification increments a number displayed on the long- press menu (visible in figure 1), but you can override this number for your app. For example, this might be useful if you're using just one notification to represent multiple new messages but you want the count here to represent the number of total new messages.

To set a custom number, call setNumber() on the notification, as shown here:

Notification notification = new NotificationCompat.Builder(MainActivity.this, CHANNEL_ID)
        .setContentTitle("New Messages")
        .setContentText("You've received 3 new messages.")

Modify a notification's long-press menu icon

The long-press menu displays the large or small icon associated with a notification if available. By default, the system displays the large icon, but you can call Notification.Builder.setBadgeIconType() and pass in the BADGE_ICON_SMALL constant to display the small icon.

Notification notification = new NotificationCompat.Builder(MainActivity.this, CHANNEL_ID)
        .setContentTitle("New Messages")
        .setContentText("You've received 3 new messages.")

Hide a duplicate shortcut

If your app creates a notification that duplicates an app shortcut, you can temporarily hide the shortcut while the notification is active by calling setShortcutId().

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)