Skip to content

Most visited

Recently visited

navigation

NotificationManagerCompat

public final class NotificationManagerCompat
extends Object

java.lang.Object
   ↳ android.support.v4.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.

Public methods

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.

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.

void notify(int id, Notification notification)

Post a notification to be shown in the status bar, stream, etc.

void notify(String tag, int id, Notification notification)

Post a notification to be shown in the status bar, stream, etc.

Inherited methods

From class java.lang.Object

Constants

ACTION_BIND_SIDE_CHANNEL

String ACTION_BIND_SIDE_CHANNEL

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 NotificationListenerService.

Constant Value: "android.support.BIND_NOTIFICATION_SIDE_CHANNEL"

EXTRA_USE_SIDE_CHANNEL

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.

Constant Value: "android.support.useSideChannel"

Public methods

cancel

void cancel (int id)

Cancel a previously shown notification.

Parameters
id int: the ID of the notification

cancel

void cancel (String tag, 
                int id)

Cancel a previously shown notification.

Parameters
tag String: the string identifier of the notification.
id int: the ID of the notification

cancelAll

void cancelAll ()

Cancel all previously shown notifications.

from

NotificationManagerCompat from (Context context)

Get a NotificationManagerCompat instance for a provided context.

Parameters
context Context
Returns
NotificationManagerCompat

getEnabledListenerPackages

Set<String> getEnabledListenerPackages (Context context)

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

Parameters
context Context
Returns
Set<String>

notify

void notify (int id, 
                Notification notification)

Post a notification to be shown in the status bar, stream, etc.

Parameters
id int: the ID of the notification
notification Notification: the notification to post to the system

notify

void notify (String tag, 
                int id, 
                Notification notification)

Post a notification to be shown in the status bar, stream, etc.

Parameters
tag String: the string identifier for a notification. Can be null.
id int: the ID of the notification. The pair (tag, id) must be unique within your app.
notification Notification: the notification to post to the system
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

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.