NotificationManagerCompat

public final class NotificationManagerCompat
extends Object

java.lang.Object
   ↳ androidx.core.app.NotificationManagerCompat


Compatibility library for NotificationManager with fallbacks for older platforms.

To use this class, call the static function from(Context) to get a NotificationManagerCompat object, and then call one of its methods to post or cancel notifications.

Summary

Constants

String ACTION_BIND_SIDE_CHANNEL

Intent action to register for on a service to receive side channel notifications.

String EXTRA_USE_SIDE_CHANNEL

Notification extras key: if set to true, the posted notification should use the side channel for delivery instead of using notification manager.

int IMPORTANCE_DEFAULT

Default notification importance: shows everywhere, allowed to makes noise, but does not visually intrude.

int IMPORTANCE_HIGH

Higher notification importance: shows everywhere, allowed to makes noise and peek.

int IMPORTANCE_LOW

Low notification importance: shows everywhere, but is not intrusive.

int IMPORTANCE_MAX

Highest notification importance: shows everywhere, allowed to makes noise, peek, and use full screen intents.

int IMPORTANCE_MIN

Min notification importance: only shows in the shade, below the fold.

int IMPORTANCE_NONE

A notification with no importance: shows nowhere, is blocked.

int IMPORTANCE_UNSPECIFIED

Value signifying that the user has not expressed an importance.

Public methods

boolean areNotificationsEnabled()

Returns whether notifications from the calling package are not blocked.

void cancel(int id)

Cancel a previously shown notification.

void cancel(String tag, int id)

Cancel a previously shown notification.

void cancelAll()

Cancel all previously shown notifications.

void createNotificationChannel(NotificationChannel channel)

Creates a notification channel that notifications can be posted to.

void createNotificationChannel(NotificationChannelCompat channel)

Creates a notification channel that notifications can be posted to.

void createNotificationChannelGroup(NotificationChannelGroup group)

Creates a group container for NotificationChannel objects.

void createNotificationChannelGroup(NotificationChannelGroupCompat group)

Creates a group container for NotificationChannel objects.

void createNotificationChannelGroups(List<NotificationChannelGroup> groups)

Creates multiple notification channel groups.

void createNotificationChannelGroupsCompat(List<NotificationChannelGroupCompat> groups)

Creates multiple notification channel groups.

void createNotificationChannels(List<NotificationChannel> channels)

Creates multiple notification channels that different notifications can be posted to.

void createNotificationChannelsCompat(List<NotificationChannelCompat> channels)

Creates multiple notification channels that different notifications can be posted to.

void deleteNotificationChannel(String channelId)

Deletes the given notification channel.

void deleteNotificationChannelGroup(String groupId)

Deletes the given notification channel group, and all notification channels that belong to it.

void deleteUnlistedNotificationChannels(Collection<String> channelIds)

Deletes notification channels for which ids are NOT given.

static NotificationManagerCompat from(Context context)

Get a NotificationManagerCompat instance for a provided context.

static Set<String> getEnabledListenerPackages(Context context)

Get the set of packages that have an enabled notification listener component within them.

int getImportance()

Returns the user specified importance for notifications from the calling package.

NotificationChannel getNotificationChannel(String channelId)

Returns the notification channel settings for a given channel id.

NotificationChannel getNotificationChannel(String channelId, String conversationId)

Returns the notification channel settings for a given channel and conversation id.

NotificationChannelCompat getNotificationChannelCompat(String channelId, String conversationId)

Returns the notification channel settings for a given channel and conversation id.

NotificationChannelCompat getNotificationChannelCompat(String channelId)

Returns the notification channel settings for a given channel id.