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 a previously shown notification. |
Unit |
Cancel a previously shown notification. |
Unit |
Cancel all previously shown notifications. |
Unit |
createNotificationChannel(@NonNull channel: NotificationChannel) Creates a notification channel that notifications can be posted to. |
Unit |
createNotificationChannel(@NonNull channel: NotificationChannelCompat) Creates a notification channel that notifications can be posted to. |
Unit |
createNotificationChannelGroup(@NonNull group: NotificationChannelGroup) Creates a group container for |
Unit |
createNotificationChannelGroup(@NonNull group: NotificationChannelGroupCompat) Creates a group container for |
Unit |
createNotificationChannelGroups(@NonNull groups: MutableList<NotificationChannelGroup!>) Creates multiple notification channel groups. |
Unit |
createNotificationChannelGroupsCompat(@NonNull groups: MutableList<NotificationChannelGroupCompat!>) Creates multiple notification channel groups. |
Unit |
createNotificationChannels(@NonNull channels: MutableList<NotificationChannel!>) Creates multiple notification channels that different notifications can be posted to. |
Unit |
createNotificationChannelsCompat(@NonNull channels: MutableList<NotificationChannelCompat!>) Creates multiple notification channels that different notifications can be posted to. |
Unit |
deleteNotificationChannel(@NonNull channelId: String) Deletes the given notification channel. |
Unit |
deleteNotificationChannelGroup(@NonNull groupId: String) Deletes the given notification channel group, and all notification channels that belong to it. |
Unit |
deleteUnlistedNotificationChannels(@NonNull channelIds: MutableCollection<String!>) Deletes notification channels for which ids are NOT given. |
static NotificationManagerCompat |
Get a |
static MutableSet<String!> |
getEnabledListenerPackages(@NonNull context: Context) 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 |
NotificationChannelCompat? |
getNotificationChannelCompat(@NonNull channelId: String) Returns the notification channel settings for a given channel id. |
NotificationChannelCompat? |
getNotificationChannelCompat(@NonNull channelId: String, @NonNull conversationId: String) Returns the notification channel settings for a given channel and |
NotificationChannelGroup? |
getNotificationChannelGroup(@NonNull channelGroupId: String) Returns the notification channel group settings for a given channel group id. |
NotificationChannelGroupCompat? |
getNotificationChannelGroupCompat(@NonNull channelGroupId: String) Returns the notification channel group settings for a given channel group id. |
MutableList<NotificationChannelGroup!> |
Returns all notification channel groups belonging to the calling app or an empty list on older SDKs which don't support Notification Channels. |
MutableList<NotificationChannelGroupCompat!> |
Returns all notification channel groups belonging to the calling app or an empty list on older SDKs which don't support Notification Channels. |
MutableList<NotificationChannel!> |
Returns all notification channels belonging to the calling app or an empty list on older SDKs which don't support Notification Channels. |
MutableList<NotificationChannelCompat!> |
Returns all notification channels belonging to the calling app or an empty list on older SDKs which don't support Notification Channels. |
Unit |
notify(id: Int, @NonNull notification: Notification) Post a notification to be shown in the status bar, stream, etc. |
Unit |
notify(@Nullable tag: String?, id: Int, @NonNull notification: Notification) Post a notification to be shown in the status bar, stream, etc. |
Constants
ACTION_BIND_SIDE_CHANNEL
static val ACTION_BIND_SIDE_CHANNEL: String
Intent action to register for on a service to receive side channel notifications. The listening service must be in the same package as an enabled android.service.notification.NotificationListenerService
.
Value: "android.support.BIND_NOTIFICATION_SIDE_CHANNEL"
EXTRA_USE_SIDE_CHANNEL
static val EXTRA_USE_SIDE_CHANNEL: String
Notification extras key: if set to true, the posted notification should use the side channel for delivery instead of using notification manager.
Value: "android.support.useSideChannel"
IMPORTANCE_DEFAULT
static val IMPORTANCE_DEFAULT: Int
Default notification importance: shows everywhere, allowed to makes noise, but does not visually intrude.
Value: 3
IMPORTANCE_HIGH
static val IMPORTANCE_HIGH: Int
Higher notification importance: shows everywhere, allowed to makes noise and peek.
Value: 4
IMPORTANCE_LOW
static val IMPORTANCE_LOW: Int
Low notification importance: shows everywhere, but is not intrusive.
Value: 2
IMPORTANCE_MAX
static val IMPORTANCE_MAX: Int
Highest notification importance: shows everywhere, allowed to makes noise, peek, and use full screen intents.
Value: 5
IMPORTANCE_MIN
static val IMPORTANCE_MIN: Int
Min notification importance: only shows in the shade, below the fold.
Value: 1
IMPORTANCE_NONE
static val IMPORTANCE_NONE: Int
A notification with no importance: shows nowhere, is blocked.
Value: 0
IMPORTANCE_UNSPECIFIED
static val IMPORTANCE_UNSPECIFIED: Int
Value signifying that the user has not expressed an importance. This value is for persisting preferences, and should never be associated with an actual notification.
Value: -1000
Public methods
areNotificationsEnabled
fun areNotificationsEnabled(): Boolean
Returns whether notifications from the calling package are not blocked.