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.
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(String tag, int id)
Cancel a previously shown notification. |
void
|
cancel(int id)
Cancel a previously shown notification. |
void
|
cancelAll()
Cancel all previously shown notifications. |
static
NotificationManagerCompat
|
from(Context context)
Get a |
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. |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
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"
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"
int IMPORTANCE_DEFAULT
Default notification importance: shows everywhere, allowed to makes noise, but does not visually intrude.
Constant Value: 3 (0x00000003)
int IMPORTANCE_HIGH
Higher notification importance: shows everywhere, allowed to makes noise and peek.
Constant Value: 4 (0x00000004)
int IMPORTANCE_LOW
Low notification importance: shows everywhere, but is not intrusive.
Constant Value: 2 (0x00000002)
int IMPORTANCE_MAX
Highest notification importance: shows everywhere, allowed to makes noise, peek, and use full screen intents.
Constant Value: 5 (0x00000005)
int IMPORTANCE_MIN
Min notification importance: only shows in the shade, below the fold.
Constant Value: 1 (0x00000001)
int IMPORTANCE_NONE
A notification with no importance: shows nowhere, is blocked.
Constant Value: 0 (0x00000000)
int IMPORTANCE_UNSPECIFIED
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.
Constant Value: -1000 (0xfffffc18)
boolean areNotificationsEnabled ()
Returns whether notifications from the calling package are not blocked.
Returns | |
---|---|
boolean |
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
|
void cancel (int id)
Cancel a previously shown notification.
Parameters | |
---|---|
id |
int :
the ID of the notification
|
void cancelAll ()
Cancel all previously shown notifications.
NotificationManagerCompat from (Context context)
Get a NotificationManagerCompat
instance for a provided context.
Parameters | |
---|---|
context |
Context
|
Returns | |
---|---|
NotificationManagerCompat |
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> |
int getImportance ()
Returns the user specified importance for notifications from the calling package.
Returns | |
---|---|
int |
An importance level, such as IMPORTANCE_DEFAULT .
|
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
|
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
|