public final class NotificationManagerCompat extends Object
To use this class, call the static function from(android.content.Context)
to get a
NotificationManagerCompat
object, and then call one of its
methods to post or cancel notifications.
Modifier and Type | Field and Description |
---|---|
static String |
ACTION_BIND_SIDE_CHANNEL
Intent action to register for on a service to receive side channel
notifications.
|
static 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.
|
static int |
IMPORTANCE_DEFAULT
Default notification importance: shows everywhere, allowed to makes noise,
but does not visually intrude.
|
static int |
IMPORTANCE_HIGH
Higher notification importance: shows everywhere, allowed to makes noise and peek.
|
static int |
IMPORTANCE_LOW
Low notification importance: shows everywhere, but is not intrusive.
|
static int |
IMPORTANCE_MAX
Highest notification importance: shows everywhere, allowed to makes noise, peek, and
use full screen intents.
|
static int |
IMPORTANCE_MIN
Min notification importance: only shows in the shade, below the fold.
|
static int |
IMPORTANCE_NONE
A notification with no importance: shows nowhere, is blocked.
|
static int |
IMPORTANCE_UNSPECIFIED
Value signifying that the user has not expressed an importance.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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.
|
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.
|
public static final String EXTRA_USE_SIDE_CHANNEL
public static final String ACTION_BIND_SIDE_CHANNEL
NotificationListenerService
.public static final int IMPORTANCE_UNSPECIFIED
public static final int IMPORTANCE_NONE
public static final int IMPORTANCE_MIN
public static final int IMPORTANCE_LOW
public static final int IMPORTANCE_DEFAULT
public static final int IMPORTANCE_HIGH
public static final int IMPORTANCE_MAX
public static NotificationManagerCompat from(Context context)
NotificationManagerCompat
instance for a provided context.public void cancel(int id)
id
- the ID of the notificationpublic void cancel(String tag, int id)
tag
- the string identifier of the notification.id
- the ID of the notificationpublic void cancelAll()
public void notify(int id, Notification notification)
id
- the ID of the notificationnotification
- the notification to post to the systempublic void notify(String tag, int id, Notification notification)
tag
- the string identifier for a notification. Can be null
.id
- the ID of the notification. The pair (tag, id) must be unique within your app.notification
- the notification to post to the systempublic boolean areNotificationsEnabled()
public int getImportance()
IMPORTANCE_DEFAULT
.