public class NotificationCompat extends Object
Notification
introduced after API level 4 in a backwards compatible fashion.Modifier and Type | Class and Description |
---|---|
static class |
NotificationCompat.Action
Structure to encapsulate a named action that can be shown as part of this notification.
|
static class |
NotificationCompat.BigPictureStyle
Helper class for generating large-format notifications that include a large image attachment.
|
static class |
NotificationCompat.BigTextStyle
Helper class for generating large-format notifications that include a lot of text.
|
static class |
NotificationCompat.Builder
Builder class for
NotificationCompat objects. |
protected static class |
NotificationCompat.BuilderExtender
Interface for appcompat to extend v4 builder with media style.
|
static class |
NotificationCompat.CarExtender
Helper class to add Android Auto extensions to notifications.
|
static interface |
NotificationCompat.Extender
Extender interface for use with
NotificationCompat.Builder.extend(android.support.v4.app.NotificationCompat.Extender) . |
static class |
NotificationCompat.InboxStyle
Helper class for generating large-format notifications that include a list of (up to 5) strings.
|
static class |
NotificationCompat.MessagingStyle
Helper class for generating large-format notifications that include multiple back-and-forth
messages of varying types between any number of people.
|
static class |
NotificationCompat.Style
An object that can apply a rich notification style to a
Notification.Builder
object. |
static class |
NotificationCompat.WearableExtender
Helper class to add wearable extensions to notifications.
|
Modifier and Type | Field and Description |
---|---|
static String |
CATEGORY_ALARM
Notification category: alarm or timer.
|
static String |
CATEGORY_CALL
Notification category: incoming call (voice or video) or similar synchronous communication request.
|
static String |
CATEGORY_EMAIL
Notification category: asynchronous bulk message (email).
|
static String |
CATEGORY_ERROR
Notification category: error in background operation or authentication status.
|
static String |
CATEGORY_EVENT
Notification category: calendar event.
|
static String |
CATEGORY_MESSAGE
Notification category: incoming direct message (SMS, instant message, etc.).
|
static String |
CATEGORY_PROGRESS
Notification category: progress of a long-running background operation.
|
static String |
CATEGORY_PROMO
Notification category: promotion or advertisement.
|
static String |
CATEGORY_RECOMMENDATION
Notification category: a specific, timely recommendation for a single thing.
|
static String |
CATEGORY_REMINDER
Notification category: user-scheduled reminder.
|
static String |
CATEGORY_SERVICE
Notification category: indication of running background service.
|
static String |
CATEGORY_SOCIAL
Notification category: social network or sharing update.
|
static String |
CATEGORY_STATUS
Notification category: ongoing information about device or contextual status.
|
static String |
CATEGORY_SYSTEM
Notification category: system or device status update.
|
static String |
CATEGORY_TRANSPORT
Notification category: media transport control for playback.
|
static int |
COLOR_DEFAULT
Value of
Notification.color equal to 0 (also known as
Color.TRANSPARENT ),
telling the system not to decorate this notification with any special color but instead use
default colors when presenting this notification. |
static int |
DEFAULT_ALL
Use all default values (where applicable).
|
static int |
DEFAULT_LIGHTS
Use the default notification lights.
|
static int |
DEFAULT_SOUND
Use the default notification sound.
|
static int |
DEFAULT_VIBRATE
Use the default notification vibrate.
|
static String |
EXTRA_BACKGROUND_IMAGE_URI
Notification extras key: A
content URI pointing to an image that can be displayed
in the background when the notification is selected. |
static String |
EXTRA_BIG_TEXT
Notification extras key: this is the longer text shown in the big form of a
NotificationCompat.BigTextStyle notification, as supplied to
NotificationCompat.BigTextStyle.bigText(CharSequence) . |
static String |
EXTRA_COMPACT_ACTIONS
Notification extras key: the indices of actions to be shown in the compact view,
as supplied to (e.g.)
|
static String |
EXTRA_CONVERSATION_TITLE
Notification key: a
String to be displayed as the title to a conversation
represented by a NotificationCompat.MessagingStyle |
static String |
EXTRA_INFO_TEXT
Notification extras key: this is a small piece of additional text as supplied to
NotificationCompat.Builder.setContentInfo(CharSequence) . |
static String |
EXTRA_LARGE_ICON
Notification extras key: this is a bitmap to be used instead of the small icon when showing the
notification payload, as
supplied to
NotificationCompat.Builder.setLargeIcon(android.graphics.Bitmap) . |
static String |
EXTRA_LARGE_ICON_BIG
Notification extras key: this is a bitmap to be used instead of the one from
NotificationCompat.Builder.setLargeIcon(android.graphics.Bitmap) when the notification is
shown in its expanded form, as supplied to
NotificationCompat.BigPictureStyle.bigLargeIcon(android.graphics.Bitmap) . |
static String |
EXTRA_MEDIA_SESSION
Notification key: A
MediaSession.Token associated with a
Notification.MediaStyle notification. |
static String |
EXTRA_MESSAGES
Notification key: an array of
Bundle objects representing
NotificationCompat.MessagingStyle.Message objects for a NotificationCompat.MessagingStyle notification. |
static String |
EXTRA_PEOPLE
Notification extras key: A String array containing the people that this
notification relates to, each of which was supplied to
NotificationCompat.Builder.addPerson(String) . |
static String |
EXTRA_PICTURE
Notification extras key: this is a bitmap to be shown in
NotificationCompat.BigPictureStyle expanded
notifications, supplied to NotificationCompat.BigPictureStyle.bigPicture(android.graphics.Bitmap) . |
static String |
EXTRA_PROGRESS
Notification extras key: this is the progress value supplied to
NotificationCompat.Builder.setProgress(int, int, boolean) . |
static String |
EXTRA_PROGRESS_INDETERMINATE
Notification extras key: whether the progress bar is indeterminate, supplied to
NotificationCompat.Builder.setProgress(int, int, boolean) . |
static String |
EXTRA_PROGRESS_MAX
Notification extras key: this is the maximum value supplied to
NotificationCompat.Builder.setProgress(int, int, boolean) . |
static String |
EXTRA_REMOTE_INPUT_HISTORY
Notification extras key: this is the remote input history, as supplied to
NotificationCompat.Builder.setRemoteInputHistory(CharSequence[]) . |
static String |
EXTRA_SELF_DISPLAY_NAME
Notification key: the username to be displayed for all messages sent by the user
including
direct replies
NotificationCompat.MessagingStyle notification. |
static String |
EXTRA_SHOW_CHRONOMETER
Notification extras key: whether the when field set using
NotificationCompat.Builder.setWhen(long) should
be shown as a count-up timer (specifically a Chronometer ) instead
of a timestamp, as supplied to NotificationCompat.Builder.setUsesChronometer(boolean) . |
static String |
EXTRA_SHOW_WHEN
Notification extras key: whether the when field set using
NotificationCompat.Builder.setWhen(long) should
be shown, as supplied to NotificationCompat.Builder.setShowWhen(boolean) . |
static String |
EXTRA_SMALL_ICON
Notification extras key: this is the resource ID of the notification's main small icon, as
supplied to
NotificationCompat.Builder.setSmallIcon(int) . |
static String |
EXTRA_SUB_TEXT
Notification extras key: this is a third line of text, as supplied to
NotificationCompat.Builder.setSubText(CharSequence) . |
static String |
EXTRA_SUMMARY_TEXT
Notification extras key: this is a line of summary information intended to be shown
alongside expanded notifications, as supplied to (e.g.)
|
static String |
EXTRA_TEMPLATE
Notification extras key: A string representing the name of the specific
Notification.Style used to create this notification. |
static String |
EXTRA_TEXT
Notification extras key: this is the main text payload, as supplied to
NotificationCompat.Builder.setContentText(CharSequence) . |
static String |
EXTRA_TEXT_LINES
Notification extras key: An array of CharSequences to show in
NotificationCompat.InboxStyle expanded
notifications, each of which was supplied to NotificationCompat.InboxStyle.addLine(CharSequence) . |
static String |
EXTRA_TITLE
Notification extras key: this is the title of the notification,
as supplied to
NotificationCompat.Builder.setContentTitle(CharSequence) . |
static String |
EXTRA_TITLE_BIG
Notification extras key: this is the title of the notification when shown in expanded form,
e.g. as supplied to
NotificationCompat.BigTextStyle.setBigContentTitle(CharSequence) . |
static int |
FLAG_AUTO_CANCEL
Bit set in the Notification flags field if the notification should be canceled when
it is clicked by the user.
|
static int |
FLAG_FOREGROUND_SERVICE
Bit set in the Notification flags field if this notification represents a currently
running service.
|
static int |
FLAG_GROUP_SUMMARY
Bit set in the Notification flags field if this notification is the group summary for a
group of notifications.
|
static int |
FLAG_HIGH_PRIORITY
Deprecated.
Use
NotificationCompat.Builder.setPriority(int) with a positive value. |
static int |
FLAG_INSISTENT
Bit set in the Notification flags field if
the audio will be repeated until the notification is
cancelled or the notification window is opened.
|
static int |
FLAG_LOCAL_ONLY
Bit set in the Notification flags field if this notification is relevant to the current
device only and it is not recommended that it bridge to other devices.
|
static int |
FLAG_NO_CLEAR
Bit set in the Notification flags field if the notification should not be canceled
when the user clicks the Clear all button.
|
static int |
FLAG_ONGOING_EVENT
Bit set in the Notification flags field if this notification is in
reference to something that is ongoing, like a phone call.
|
static int |
FLAG_ONLY_ALERT_ONCE
Bit set in the Notification flags field if the notification's sound,
vibrate and ticker should only be played if the notification is not already showing.
|
static int |
FLAG_SHOW_LIGHTS
Bit set in the Notification flags field when LEDs should be turned on
for this notification.
|
static int |
PRIORITY_DEFAULT
Default notification priority for
NotificationCompat.Builder.setPriority(int) . |
static int |
PRIORITY_HIGH
Higher notification priority for
NotificationCompat.Builder.setPriority(int) ,
for more important notifications or alerts. |
static int |
PRIORITY_LOW
Lower notification priority for
NotificationCompat.Builder.setPriority(int) ,
for items that are less important. |
static int |
PRIORITY_MAX
Highest notification priority for
NotificationCompat.Builder.setPriority(int) ,
for your application's most important items that require the user's
prompt attention or input. |
static int |
PRIORITY_MIN
Lowest notification priority for
NotificationCompat.Builder.setPriority(int) ;
these items might not be shown to the user except under
special circumstances, such as detailed notification logs. |
static int |
STREAM_DEFAULT
Use this constant as the value for audioStreamType to request that
the default stream type for notifications be used.
|
static int |
VISIBILITY_PRIVATE
Notification visibility: Show this notification on all lockscreens, but conceal sensitive or
private information on secure lockscreens.
|
static int |
VISIBILITY_PUBLIC
Notification visibility: Show this notification in its entirety on all lockscreens.
|
static int |
VISIBILITY_SECRET
Notification visibility: Do not reveal any part of this notification on a secure lockscreen.
|
Constructor and Description |
---|
NotificationCompat() |
Modifier and Type | Method and Description |
---|---|
static NotificationCompat.Action |
getAction(Notification notif,
int actionIndex)
Get an action on this notification in a backwards compatible
manner.
|
static int |
getActionCount(Notification notif)
Get the number of actions in this notification in a backwards compatible
manner.
|
static String |
getCategory(Notification notif)
Get the category of this notification in a backwards compatible
manner.
|
static Bundle |
getExtras(Notification notif)
Gets the
Notification.extras field from a notification in a backwards
compatible manner. |
static String |
getGroup(Notification notif)
Get the key used to group this notification into a cluster or stack
with other notifications on devices which support such rendering.
|
static boolean |
getLocalOnly(Notification notif)
Get whether or not this notification is only relevant to the current device.
|
static String |
getSortKey(Notification notif)
Get a sort key that orders this notification among other notifications from the
same package.
|
static boolean |
isGroupSummary(Notification notif)
Get whether this notification to be the group summary for a group of notifications.
|
public static final int DEFAULT_ALL
public static final int DEFAULT_SOUND
NotificationCompat.Builder.setSound(android.net.Uri)
A notification that is noisy is more likely to be presented as a heads-up notification, on some platforms.
public static final int DEFAULT_VIBRATE
NotificationCompat.Builder.setVibrate(long[])
. Using phone vibration requires the
VIBRATE
permission.
A notification that vibrates is more likely to be presented as a heads-up notification, on some platforms.
public static final int DEFAULT_LIGHTS
FLAG_SHOW_LIGHTS
bit, and values set with NotificationCompat.Builder.setLights(int, int, int)
.public static final int STREAM_DEFAULT
AudioManager.STREAM_NOTIFICATION
.public static final int FLAG_SHOW_LIGHTS
public static final int FLAG_ONGOING_EVENT
public static final int FLAG_INSISTENT
public static final int FLAG_ONLY_ALERT_ONCE
public static final int FLAG_AUTO_CANCEL
public static final int FLAG_NO_CLEAR
public static final int FLAG_FOREGROUND_SERVICE
Service.startForeground(int, android.app.Notification)
.@Deprecated public static final int FLAG_HIGH_PRIORITY
NotificationCompat.Builder.setPriority(int)
with a positive value.public static final int FLAG_LOCAL_ONLY
public static final int FLAG_GROUP_SUMMARY
NotificationCompat.Builder.setGroup(java.lang.String)
.public static final int PRIORITY_DEFAULT
NotificationCompat.Builder.setPriority(int)
.
If your application does not prioritize its own notifications,
use this value for all notifications.public static final int PRIORITY_LOW
NotificationCompat.Builder.setPriority(int)
,
for items that are less important. The UI may choose to show
these items smaller, or at a different position in the list,
compared with your app's PRIORITY_DEFAULT
items.public static final int PRIORITY_MIN
NotificationCompat.Builder.setPriority(int)
;
these items might not be shown to the user except under
special circumstances, such as detailed notification logs.public static final int PRIORITY_HIGH
NotificationCompat.Builder.setPriority(int)
,
for more important notifications or alerts. The UI may choose
to show these items larger, or at a different position in
notification lists, compared with your app's PRIORITY_DEFAULT
items.public static final int PRIORITY_MAX
NotificationCompat.Builder.setPriority(int)
,
for your application's most important items that require the user's
prompt attention or input.public static final String EXTRA_TITLE
NotificationCompat.Builder.setContentTitle(CharSequence)
.public static final String EXTRA_TITLE_BIG
NotificationCompat.BigTextStyle.setBigContentTitle(CharSequence)
.public static final String EXTRA_TEXT
NotificationCompat.Builder.setContentText(CharSequence)
.public static final String EXTRA_SUB_TEXT
NotificationCompat.Builder.setSubText(CharSequence)
.public static final String EXTRA_REMOTE_INPUT_HISTORY
NotificationCompat.Builder.setRemoteInputHistory(CharSequence[])
.
Apps can fill this through NotificationCompat.Builder.setRemoteInputHistory(CharSequence[])
with the most recent inputs that have been sent through a RemoteInput
of this
Notification and are expected to clear it once the it is no longer relevant (e.g. for chat
notifications once the other party has responded).
The extra with this key is of type CharSequence[] and contains the most recent entry at
the 0 index, the second most recent at the 1 index, etc.public static final String EXTRA_INFO_TEXT
NotificationCompat.Builder.setContentInfo(CharSequence)
.public static final String EXTRA_SUMMARY_TEXT
NotificationCompat.BigTextStyle.setSummaryText(CharSequence)
.public static final String EXTRA_BIG_TEXT
NotificationCompat.BigTextStyle
notification, as supplied to
NotificationCompat.BigTextStyle.bigText(CharSequence)
.public static final String EXTRA_SMALL_ICON
NotificationCompat.Builder.setSmallIcon(int)
.public static final String EXTRA_LARGE_ICON
NotificationCompat.Builder.setLargeIcon(android.graphics.Bitmap)
.public static final String EXTRA_LARGE_ICON_BIG
NotificationCompat.Builder.setLargeIcon(android.graphics.Bitmap)
when the notification is
shown in its expanded form, as supplied to
NotificationCompat.BigPictureStyle.bigLargeIcon(android.graphics.Bitmap)
.public static final String EXTRA_PROGRESS
NotificationCompat.Builder.setProgress(int, int, boolean)
.public static final String EXTRA_PROGRESS_MAX
NotificationCompat.Builder.setProgress(int, int, boolean)
.public static final String EXTRA_PROGRESS_INDETERMINATE
NotificationCompat.Builder.setProgress(int, int, boolean)
.public static final String EXTRA_SHOW_CHRONOMETER
NotificationCompat.Builder.setWhen(long)
should
be shown as a count-up timer (specifically a Chronometer
) instead
of a timestamp, as supplied to NotificationCompat.Builder.setUsesChronometer(boolean)
.public static final String EXTRA_SHOW_WHEN
NotificationCompat.Builder.setWhen(long)
should
be shown, as supplied to NotificationCompat.Builder.setShowWhen(boolean)
.public static final String EXTRA_PICTURE
NotificationCompat.BigPictureStyle
expanded
notifications, supplied to NotificationCompat.BigPictureStyle.bigPicture(android.graphics.Bitmap)
.public static final String EXTRA_TEXT_LINES
NotificationCompat.InboxStyle
expanded
notifications, each of which was supplied to NotificationCompat.InboxStyle.addLine(CharSequence)
.public static final String EXTRA_TEMPLATE
Notification.Style
used to create this notification.public static final String EXTRA_PEOPLE
NotificationCompat.Builder.addPerson(String)
.public static final String EXTRA_BACKGROUND_IMAGE_URI
content URI
pointing to an image that can be displayed
in the background when the notification is selected. The URI must point to an image stream
suitable for passing into
BitmapFactory.decodeStream
; all other content types will be ignored. The content provider
URI used for this purpose must require no permissions to read the image data.public static final String EXTRA_MEDIA_SESSION
MediaSession.Token
associated with a
Notification.MediaStyle
notification.public static final String EXTRA_COMPACT_ACTIONS
Notification.MediaStyle#setShowActionsInCompactView(int...)
.public static final String EXTRA_SELF_DISPLAY_NAME
NotificationCompat.MessagingStyle
notification.public static final String EXTRA_CONVERSATION_TITLE
String
to be displayed as the title to a conversation
represented by a NotificationCompat.MessagingStyle
public static final String EXTRA_MESSAGES
Bundle
objects representing
NotificationCompat.MessagingStyle.Message
objects for a NotificationCompat.MessagingStyle
notification.public static final int COLOR_DEFAULT
Notification.color
equal to 0 (also known as
Color.TRANSPARENT
),
telling the system not to decorate this notification with any special color but instead use
default colors when presenting this notification.public static final int VISIBILITY_PUBLIC
Notification.visibility
public static final int VISIBILITY_PRIVATE
Notification.visibility
public static final int VISIBILITY_SECRET
Notification.visibility
public static final String CATEGORY_CALL
public static final String CATEGORY_MESSAGE
public static final String CATEGORY_EMAIL
public static final String CATEGORY_EVENT
public static final String CATEGORY_PROMO
public static final String CATEGORY_ALARM
public static final String CATEGORY_PROGRESS
public static final String CATEGORY_SOCIAL
public static final String CATEGORY_ERROR
public static final String CATEGORY_TRANSPORT
public static final String CATEGORY_SYSTEM
public static final String CATEGORY_SERVICE
public static final String CATEGORY_REMINDER
public static final String CATEGORY_RECOMMENDATION
public static final String CATEGORY_STATUS
public static Bundle getExtras(Notification notif)
Notification.extras
field from a notification in a backwards
compatible manner. Extras field was supported from JellyBean (Api level 16)
forwards. This function will return null on older api levels.public static int getActionCount(Notification notif)
public static NotificationCompat.Action getAction(Notification notif, int actionIndex)
notif
- The notification to inspect.actionIndex
- The index of the action to retrieve.public static String getCategory(Notification notif)
notif
- The notification to inspect.public static boolean getLocalOnly(Notification notif)
Some notifications can be bridged to other devices for remote display. If this hint is set, it is recommend that this notification not be bridged.
public static String getGroup(Notification notif)
public static boolean isGroupSummary(Notification notif)
NotificationCompat.Builder.setGroup(java.lang.String)
.public static String getSortKey(Notification notif)
This sort key can also be used to order members of a notification group. See
NotificationCompat.Builder.setGroup(java.lang.String)
.
String.compareTo(String)