Android 12 Developer Preview is here! Try it out, and give us your feedback!

NotificationManagerCompat

class NotificationManagerCompat
kotlin.Any
   ↳ androidx.core.app.NotificationManagerCompat

Compatibility library for NotificationManager with fallbacks for older platforms.

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

Summary

Constants
static String

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

static String

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

Value signifying that the user has not expressed an importance.

Public methods
Boolean

Returns whether notifications from the calling package are not blocked.

Unit
cancel(id: Int)

Cancel a previously shown notification.

Unit
cancel(@Nullable tag: String?, id: Int)

Cancel a previously shown notification.

Unit

Cancel all previously shown notifications.

Unit

Creates a notification channel that notifications can be posted to.

Unit

Creates a notification channel that notifications can be posted to.

Unit

Creates a group container for NotificationChannel objects.

Unit

Creates a group container for NotificationChannel objects.

Unit

Creates multiple notification channel groups.

Unit

Creates multiple notification channel groups.

Unit

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

Unit

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

Unit
deleteNotificationChannel(@NonNull channelId: String)

Deletes the given notification channel.

Unit

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

Unit

Deletes notification channels for which ids are NOT given.

static NotificationManagerCompat
from(@NonNull context: Context)

Get a NotificationManagerCompat instance for a provided context.

static MutableSet<String!>

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

Int

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

NotificationChannel?
getNotificationChannel(@NonNull channelId: String)

Returns the notification channel settings for a given channel id.

NotificationChannel?
getNotificationChannel(@NonNull channelId: String, @NonNull conversationId: String)

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

NotificationChannelCompat?