NotificationCompat
public
class
NotificationCompat
extends Object
java.lang.Object | |
↳ | androidx.core.app.NotificationCompat |
Helper for accessing features in Notification
.
Summary
Nested classes | |
---|---|
class |
NotificationCompat.Action
Structure to encapsulate a named action that can be shown as part of this notification. |
class |
NotificationCompat.BigPictureStyle
Helper class for generating large-format notifications that include a large image attachment. |
class |
NotificationCompat.BigTextStyle
Helper class for generating large-format notifications that include a lot of text. |
class |
NotificationCompat.BubbleMetadata
Encapsulates the information needed to display a notification as a bubble. |
class |
NotificationCompat.Builder
Builder class for |
class |
NotificationCompat.CarExtender
Helper class to add Android Auto extensions to notifications. |
class |
NotificationCompat.DecoratedCustomViewStyle
Notification style for custom views that are decorated by the system. |
interface |
NotificationCompat.Extender
Extender interface for use with |
class |
NotificationCompat.InboxStyle
Helper class for generating large-format notifications that include a list of (up to 5) strings. |
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. |
class |
NotificationCompat.Style
An object that can apply a rich notification style to a |
class |
NotificationCompat.WearableExtender
Helper class to add wearable extensions to notifications. |
Constants | |
---|---|
int |
BADGE_ICON_LARGE
If this notification is being shown as a badge, use the icon provided to
|
int |
BADGE_ICON_NONE
If this notification is being shown as a badge, always show as a number. |
int |
BADGE_ICON_SMALL
If this notification is being shown as a badge, use the icon provided to
|
String |
CATEGORY_ALARM
Notification category: alarm or timer. |
String |
CATEGORY_CALL
Notification category: incoming call (voice or video) or similar synchronous communication request. |
String |
CATEGORY_EMAIL
Notification category: asynchronous bulk message (email). |
String |
CATEGORY_ERROR
Notification category: error in background operation or authentication status. |
String |
CATEGORY_EVENT
Notification category: calendar event. |
String |
CATEGORY_LOCATION_SHARING
Notification category: temporarily sharing location. |
String |
CATEGORY_MESSAGE
Notification category: incoming direct message (SMS, instant message, etc.). |
String |
CATEGORY_MISSED_CALL
Notification category: missed call. |
String |
CATEGORY_NAVIGATION
Notification category: map turn-by-turn navigation. |
String |
CATEGORY_PROGRESS
Notification category: progress of a long-running background operation. |
String |
CATEGORY_PROMO
Notification category: promotion or advertisement. |
String |
CATEGORY_RECOMMENDATION
Notification category: a specific, timely recommendation for a single thing. |
String |
CATEGORY_REMINDER
Notification category: user-scheduled reminder. |
String |
CATEGORY_SERVICE
Notification category: indication of running background service. |
String |
CATEGORY_SOCIAL
Notification category: social network or sharing update. |
String |
CATEGORY_STATUS
Notification category: ongoing information about device or contextual status. |
String |
CATEGORY_STOPWATCH
Notification category: running stopwatch. |
String |
CATEGORY_SYSTEM
Notification category: system or device status update. |
String |
CATEGORY_TRANSPORT
Notification category: media transport control for playback. |
String |
CATEGORY_WORKOUT
Notification category: tracking a user's workout. |
int |
COLOR_DEFAULT
Value of |
int |
DEFAULT_ALL
Use all default values (where applicable). |
int |
DEFAULT_LIGHTS
Use the default notification lights. |
int |
DEFAULT_SOUND
Use the default notification sound. |
int |
DEFAULT_VIBRATE
Use the default notification vibrate. |
String |
EXTRA_AUDIO_CONTENTS_URI
Keys into the |
String |
EXTRA_BACKGROUND_IMAGE_URI
|
String |
EXTRA_BIG_TEXT
|
String |
EXTRA_CHANNEL_GROUP_ID
Optional extra for |
String |
EXTRA_CHANNEL_ID
Optional extra for |
String |
EXTRA_CHRONOMETER_COUNT_DOWN
|
String |
EXTRA_COLORIZED
|
String |
EXTRA_COMPACT_ACTIONS
|
String |
EXTRA_COMPAT_TEMPLATE
|
String |
EXTRA_CONVERSATION_TITLE
|
String |
EXTRA_HIDDEN_CONVERSATION_TITLE
Key for compat's |
String |
EXTRA_HISTORIC_MESSAGES
|
String |
EXTRA_INFO_TEXT
|
String |
EXTRA_IS_GROUP_CONVERSATION
|
String |
EXTRA_LARGE_ICON
|
String |
EXTRA_LARGE_ICON_BIG
|
String |
EXTRA_MEDIA_SESSION
Notification key: A
|
String |
EXTRA_MESSAGES
|
String |
EXTRA_MESSAGING_STYLE_USER
|
String |
EXTRA_NOTIFICATION_ID
Optional extra for |
String |
EXTRA_NOTIFICATION_TAG
Optional extra for |
String |
EXTRA_PEOPLE
This constant is deprecated.
the actual objects are now in |
String |
EXTRA_PEOPLE_LIST
|
String |
EXTRA_PICTURE
|
String |
EXTRA_PROGRESS
|
String |
EXTRA_PROGRESS_INDETERMINATE
|
String |
EXTRA_PROGRESS_MAX
|
String |
EXTRA_REMOTE_INPUT_HISTORY
|
String |
EXTRA_SELF_DISPLAY_NAME
|
String |
EXTRA_SHOW_CHRONOMETER
|
String |
EXTRA_SHOW_WHEN
|
String |
EXTRA_SMALL_ICON
|
String |
EXTRA_SUB_TEXT
|
String |
EXTRA_SUMMARY_TEXT
|
String |
EXTRA_TEMPLATE
|
String |
EXTRA_TEXT
|
String |
EXTRA_TEXT_LINES
|
String |
EXTRA_TITLE
|
String |
EXTRA_TITLE_BIG
|
int |
FLAG_AUTO_CANCEL
Bit set in the Notification flags field if the notification should be canceled when it is clicked by the user. |
int |
FLAG_BUBBLE
Bit set in the Notification flags field if this notification is showing as a bubble. |
int |
FLAG_FOREGROUND_SERVICE
Bit set in the Notification flags field if this notification represents a currently running service. |
int |
FLAG_GROUP_SUMMARY
Bit set in the Notification flags field if this notification is the group summary for a group of notifications. |
int |
FLAG_HIGH_PRIORITY
This constant is deprecated.
Use |
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. |
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. |
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. |
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. |
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. |
int |
FLAG_SHOW_LIGHTS
Bit set in the Notification flags field when LEDs should be turned on for this notification. |
int |
GROUP_ALERT_ALL
Constant for |
int |
GROUP_ALERT_CHILDREN
Constant for |
int |
GROUP_ALERT_SUMMARY
Constant for |
String |
GROUP_KEY_SILENT
Constant for the |
String |
INTENT_CATEGORY_NOTIFICATION_PREFERENCES
An activity that provides a user interface for adjusting notification preferences for its containing application. |
int |
PRIORITY_DEFAULT
Default notification priority for |
int |
PRIORITY_HIGH
Higher notification priority for |
int |
PRIORITY_LOW
Lower notification priority for |
int |
PRIORITY_MAX
Highest notification priority for |
int |
PRIORITY_MIN
Lowest notification priority for |
int |
STREAM_DEFAULT
Use this constant as the value for audioStreamType to request that the default stream type for notifications be used. |
int |
VISIBILITY_PRIVATE
Notification visibility: Show this notification on all lockscreens, but conceal sensitive or private information on secure lockscreens. |
int |
VISIBILITY_PUBLIC
Notification visibility: Show this notification in its entirety on all lockscreens. |
int |
VISIBILITY_SECRET
Notification visibility: Do not reveal any part of this notification on a secure lockscreen. |
Public constructors | |
---|---|
NotificationCompat()
This constructor is deprecated. This type should not be instantiated as it contains only static methods. |
Public methods | |
---|---|
static
NotificationCompat.Action
|
getAction(Notification notification, int actionIndex)
Get an action on this notification in a backwards compatible manner. |
static
int
|
getActionCount(Notification notification)
Get the number of actions in this notification in a backwards compatible manner. |
static
boolean
|
getAllowSystemGeneratedContextualActions(Notification notification)
Returns whether the platform is allowed (by the app developer) to generate contextual actions for this notification. |
static
boolean
|
getAutoCancel(Notification notification)
Get the value provided to |
static
int
|
getBadgeIconType(Notification notification)
Returns what icon should be shown for this notification if it is being displayed in a Launcher that supports badging. |
static
NotificationCompat.BubbleMetadata
|
getBubbleMetadata(Notification notification)
Get the |
static
String
|
getCategory(Notification notification)
Get the category of this notification in a backwards compatible manner. |
static
String
|
getChannelId(Notification notification)
|
static
int
|
getColor(Notification notification)
Get the value provided to |
static
CharSequence
|
getContentInfo(Notification notification)
Returns the content info provided to |
static
CharSequence
|
getContentText(Notification notification)
Returns the content text provided to |
static
CharSequence
|
getContentTitle(Notification notification)
Returns the content title provided to |
static
Bundle
|
getExtras(Notification notification)
Gets the |
static
String
|
getGroup(Notification notification)
Get the key used to group this notification into a cluster or stack with other notifications on devices which support such rendering. |
static
int
|
getGroupAlertBehavior(Notification notification)
Returns which type of notifications in a group are responsible for audibly alerting the user. |
static
List<NotificationCompat.Action>
|
getInvisibleActions(Notification notification)
Returns the invisible actions contained within the given notification. |
static
boolean
|
getLocalOnly(Notification notification)
Get whether or not this notification is only relevant to the current device. |
static
LocusIdCompat
|
getLocusId(Notification notification)
Gets the |
static
boolean
|
getOngoing(Notification notification)
Get the value provided to |
static
boolean
|
getOnlyAlertOnce(Notification notification)
Get the value provided to |
static
List<Person>
|
getPeople(Notification notification)
Returns the people in the notification. |
static
Notification
|
getPublicVersion(Notification notification)
Get the value provided to |
static
CharSequence
|
getSettingsText(Notification notification)
Returns the settings text provided to |
static
String
|
getShortcutId(Notification notification)
Returns the |
static
boolean
|
getShowWhen(Notification notification)
Get the value provided to |
static
String
|
getSortKey(Notification notification)
Get a sort key that orders this notification among other notifications from the same package. |
static
CharSequence
|
getSubText(Notification notification)
Returns the sub text provided to |
static
long
|
getTimeoutAfter(Notification notification)
Returns the time at which this notification should be canceled by the system, if it's not canceled already. |
static
boolean
|
getUsesChronometer(Notification notification)
Get the value provided to |
static
int
|
getVisibility(Notification notification)
Get the value provided to |
static
boolean
|
isGroupSummary(Notification notification)
Get whether this notification to be the group summary for a group of notifications. |
Inherited methods | |
---|---|
Constants
BADGE_ICON_LARGE
public static final int BADGE_ICON_LARGE
If this notification is being shown as a badge, use the icon provided to
NotificationCompat.Builder.setLargeIcon(Bitmap)
to represent this notification.
Constant Value: 2 (0x00000002)
BADGE_ICON_NONE
public static final int BADGE_ICON_NONE
If this notification is being shown as a badge, always show as a number.
Constant Value: 0 (0x00000000)
BADGE_ICON_SMALL
public static final int BADGE_ICON_SMALL
If this notification is being shown as a badge, use the icon provided to
NotificationCompat.Builder.setSmallIcon(int)
to represent this notification.
Constant Value: 1 (0x00000001)
CATEGORY_ALARM
public static final String CATEGORY_ALARM
Notification category: alarm or timer.
Constant Value: "alarm"
CATEGORY_CALL
public static final String CATEGORY_CALL
Notification category: incoming call (voice or video) or similar synchronous communication request.
Constant Value: "call"
CATEGORY_EMAIL
public static final String CATEGORY_EMAIL
Notification category: asynchronous bulk message (email).
Constant Value: "email"
CATEGORY_ERROR
public static final String CATEGORY_ERROR
Notification category: error in background operation or authentication status.
Constant Value: "err"
CATEGORY_EVENT
public static final String CATEGORY_EVENT
Notification category: calendar event.
Constant Value: "event"
CATEGORY_LOCATION_SHARING
public static final String CATEGORY_LOCATION_SHARING
Notification category: temporarily sharing location.
Constant Value: "location_sharing"
CATEGORY_MESSAGE
public static final String CATEGORY_MESSAGE
Notification category: incoming direct message (SMS, instant message, etc.).
Constant Value: "msg"
CATEGORY_MISSED_CALL
public static final String CATEGORY_MISSED_CALL
Notification category: missed call.
Constant Value: "missed_call"
CATEGORY_NAVIGATION
public static final String CATEGORY_NAVIGATION
Notification category: map turn-by-turn navigation.
Constant Value: "navigation"
CATEGORY_PROGRESS
public static final String CATEGORY_PROGRESS
Notification category: progress of a long-running background operation.
Constant Value: "progress"
CATEGORY_PROMO
public static final String CATEGORY_PROMO
Notification category: promotion or advertisement.
Constant Value: "promo"
CATEGORY_RECOMMENDATION
public static final String CATEGORY_RECOMMENDATION
Notification category: a specific, timely recommendation for a single thing. For example, a news app might want to recommend a news story it believes the user will want to read next.
Constant Value: "recommendation"
CATEGORY_REMINDER
public static final String CATEGORY_REMINDER
Notification category: user-scheduled reminder.
Constant Value: "reminder"
CATEGORY_SERVICE
public static final String CATEGORY_SERVICE
Notification category: indication of running background service.
Constant Value: "service"
CATEGORY_SOCIAL
public static final String CATEGORY_SOCIAL
Notification category: social network or sharing update.
Constant Value: "social"
CATEGORY_STATUS
public static final String CATEGORY_STATUS
Notification category: ongoing information about device or contextual status.
Constant Value: "status"
CATEGORY_STOPWATCH
public static final String CATEGORY_STOPWATCH
Notification category: running stopwatch.
Constant Value: "stopwatch"
CATEGORY_SYSTEM
public static final String CATEGORY_SYSTEM
Notification category: system or device status update. Reserved for system use.
Constant Value: "sys"
CATEGORY_TRANSPORT
public static final String CATEGORY_TRANSPORT
Notification category: media transport control for playback.
Constant Value: "transport"
CATEGORY_WORKOUT
public static final String CATEGORY_WORKOUT
Notification category: tracking a user's workout.
Constant Value: "workout"
COLOR_DEFAULT
public static final 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.
Constant Value: 0 (0x00000000)
DEFAULT_ALL
public static final int DEFAULT_ALL
Use all default values (where applicable).
Constant Value: -1 (0xffffffff)
DEFAULT_LIGHTS
public static final int DEFAULT_LIGHTS
Use the default notification lights. This will ignore the
FLAG_SHOW_LIGHTS
bit, and values set with NotificationCompat.Builder.setLights(int, int, int)
.
Constant Value: 4 (0x00000004)
DEFAULT_SOUND
public static final int DEFAULT_SOUND
Use the default notification sound. This will ignore any sound set using
NotificationCompat.Builder.setSound(Uri)
A notification that is noisy is more likely to be presented as a heads-up notification, on some platforms.
Constant Value: 1 (0x00000001)
DEFAULT_VIBRATE
public static final int DEFAULT_VIBRATE
Use the default notification vibrate. This will ignore any vibrate set using
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.
Constant Value: 2 (0x00000002)
EXTRA_AUDIO_CONTENTS_URI
public static final String EXTRA_AUDIO_CONTENTS_URI
Keys into the getExtras(Notification)
Bundle: the audio contents of this notification.
This is for use when rendering the notification on an audio-focused interface;
the audio contents are a complete sound sample that contains the contents/body of the
notification. This may be used in substitute of a Text-to-Speech reading of the
notification. For example if the notification represents a voice message this should point
to the audio of that message.
The data stored under this key should be a String representation of a Uri that contains the
audio contents in one of the following formats: WAV, PCM 16-bit, AMR-WB.
This extra is unnecessary if you are using MessagingStyle
since each Message
has a field for holding data URI. That field can be used for audio.
See Message#setData
.
Example usage:
NotificationCompat.Builder myBuilder = (build your Notification as normal);
myBuilder.getExtras().putString(EXTRA_AUDIO_CONTENTS_URI, myAudioUri.toString());
Constant Value: "android.audioContents"
EXTRA_BACKGROUND_IMAGE_URI
public static final String EXTRA_BACKGROUND_IMAGE_URI
extras
key: A
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.
Constant Value: "android.backgroundImageUri"
EXTRA_BIG_TEXT
public static final String EXTRA_BIG_TEXT
extras
key: this is the longer text shown in the big form of a
NotificationCompat.BigTextStyle
notification, as supplied to
NotificationCompat.BigTextStyle.bigText(CharSequence)
.
Constant Value: "android.bigText"
EXTRA_CHANNEL_GROUP_ID
public static final String EXTRA_CHANNEL_GROUP_ID
Optional extra for INTENT_CATEGORY_NOTIFICATION_PREFERENCES
. If provided, will
contain a group id
that can be used to narrow
down what settings should be shown in the target app.
Constant Value: "android.intent.extra.CHANNEL_GROUP_ID"
EXTRA_CHANNEL_ID
public static final String EXTRA_CHANNEL_ID
Optional extra for INTENT_CATEGORY_NOTIFICATION_PREFERENCES
. If provided, will
contain a channel id
that can be used to narrow
down what settings should be shown in the target app.
Constant Value: "android.intent.extra.CHANNEL_ID"
EXTRA_CHRONOMETER_COUNT_DOWN
public static final String EXTRA_CHRONOMETER_COUNT_DOWN
extras
key: whether the chronometer set on the notification should count
down instead of counting up. Is only relevant if key EXTRA_SHOW_CHRONOMETER
is
present. This extra is a boolean. The default is (@code false).
Constant Value: "android.chronometerCountDown"
EXTRA_COLORIZED
public static final String EXTRA_COLORIZED
extras
key: whether the notification should be colorized as
supplied to NotificationCompat.Builder.setColorized(boolean)
.
Constant Value: "android.colorized"
EXTRA_COMPACT_ACTIONS
public static final String EXTRA_COMPACT_ACTIONS
extras
key: the indices of actions to be shown in the compact view,
as supplied to (e.g.) Notification.MediaStyle.setShowActionsInCompactView(int)
.
Constant Value: "android.compactActions"
EXTRA_COMPAT_TEMPLATE
public static final String EXTRA_COMPAT_TEMPLATE
extras
key: A string representing the name of the specific
NotificationCompat.Style
used to create this notification.
Constant Value: "androidx.core.app.extra.COMPAT_TEMPLATE"
EXTRA_CONVERSATION_TITLE
public static final String EXTRA_CONVERSATION_TITLE
extras
key: a String
to be displayed as the title to a
conversation represented by a NotificationCompat.MessagingStyle
.
Constant Value: "android.conversationTitle"
EXTRA_HIDDEN_CONVERSATION_TITLE
public static final String EXTRA_HIDDEN_CONVERSATION_TITLE
Key for compat's NotificationCompat.MessagingStyle.getConversationTitle()
. This allows backwards support
for conversation titles as SDK < P uses the title to denote group status. This hidden title
doesn't appear in the notification shade.
Constant Value: "android.hiddenConversationTitle"
EXTRA_HISTORIC_MESSAGES
public static final String EXTRA_HISTORIC_MESSAGES
extras
key: an array of historic
NotificationCompat.MessagingStyle.Message
bundles provided by a NotificationCompat.MessagingStyle
notification.
This extra is a parcelable array of Bundle
objects.
Constant Value: "android.messages.historic"
EXTRA_INFO_TEXT
public static final String EXTRA_INFO_TEXT
extras
key: this is a small piece of additional text as supplied to
NotificationCompat.Builder.setContentInfo(CharSequence)
.
Constant Value: "android.infoText"
EXTRA_IS_GROUP_CONVERSATION
public static final String EXTRA_IS_GROUP_CONVERSATION
extras
key: whether the NotificationCompat.MessagingStyle
notification represents a group conversation.
Constant Value: "android.isGroupConversation"
EXTRA_LARGE_ICON
public static final String EXTRA_LARGE_ICON
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)
.
Constant Value: "android.largeIcon"
EXTRA_LARGE_ICON_BIG
public static final String EXTRA_LARGE_ICON_BIG
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)
.
Constant Value: "android.largeIcon.big"
EXTRA_MEDIA_SESSION
public static final String EXTRA_MEDIA_SESSION
Notification key: A
MediaSession.Token
associated with a
Notification.MediaStyle
notification.
Constant Value: "android.mediaSession"
EXTRA_MESSAGES
public static final String EXTRA_MESSAGES
extras
key: an array of NotificationCompat.MessagingStyle.Message
bundles provided by a Notification.MessagingStyle
notification.
This extra is a parcelable array of Bundle
objects.
Constant Value: "android.messages"
EXTRA_MESSAGING_STYLE_USER
public static final String EXTRA_MESSAGING_STYLE_USER
extras
key: the person to display for all messages sent by the user,
including direct replies to NotificationCompat.MessagingStyle
notifications.
Constant Value: "android.messagingStyleUser"
EXTRA_NOTIFICATION_ID
public static final String EXTRA_NOTIFICATION_ID
Optional extra for INTENT_CATEGORY_NOTIFICATION_PREFERENCES
. If provided, will
contain the id provided to
NotificationManagerCompat.notify(String, int, Notification)
that can be used to narrow down what settings should be shown in the target app.
Constant Value: "android.intent.extra.NOTIFICATION_ID"
EXTRA_NOTIFICATION_TAG
public static final String EXTRA_NOTIFICATION_TAG
Optional extra for INTENT_CATEGORY_NOTIFICATION_PREFERENCES
. If provided, will
contain the tag provided to
NotificationManagerCompat.notify(String, int, Notification)
that can be used to narrow down what settings should be shown in the target app.
Constant Value: "android.intent.extra.NOTIFICATION_TAG"
EXTRA_PEOPLE
public static final String EXTRA_PEOPLE
This constant is deprecated.
the actual objects are now in EXTRA_PEOPLE_LIST
extras
key: A String array containing the people that this
notification relates to, each of which was supplied to
NotificationCompat.Builder.addPerson(String)
.
Constant Value: "android.people"
EXTRA_PEOPLE_LIST
public static final String EXTRA_PEOPLE_LIST
extras
key: : An arrayList of Person
objects containing the
people that this notification relates to, each of which was supplied to
NotificationCompat.Builder.addPerson(Person)
.
Constant Value: "android.people.list"
EXTRA_PICTURE
public static final String EXTRA_PICTURE
extras
key: this is a bitmap to be shown in NotificationCompat.BigPictureStyle
expanded notifications, supplied to
NotificationCompat.BigPictureStyle.bigPicture(android.graphics.Bitmap)
.
Constant Value: "android.picture"
EXTRA_PROGRESS
public static final String EXTRA_PROGRESS
extras
key: this is the progress value supplied to
NotificationCompat.Builder.setProgress(int, int, boolean)
.
Constant Value: "android.progress"
EXTRA_PROGRESS_INDETERMINATE
public static final String EXTRA_PROGRESS_INDETERMINATE
extras
key: whether the progress bar is indeterminate, supplied to
NotificationCompat.Builder.setProgress(int, int, boolean)
.
Constant Value: "android.progressIndeterminate"
EXTRA_PROGRESS_MAX
public static final String EXTRA_PROGRESS_MAX
extras
key: this is the maximum value supplied to
NotificationCompat.Builder.setProgress(int, int, boolean)
.
Constant Value: "android.progressMax"
EXTRA_REMOTE_INPUT_HISTORY
public static final String EXTRA_REMOTE_INPUT_HISTORY
extras
key: this is the remote input history, as supplied to
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.
Constant Value: "android.remoteInputHistory"
EXTRA_SELF_DISPLAY_NAME
public static final String EXTRA_SELF_DISPLAY_NAME
extras
key: the username to be displayed for all messages sent by the
user including direct replies NotificationCompat.MessagingStyle
notification.
Constant Value: "android.selfDisplayName"
EXTRA_SHOW_CHRONOMETER
public static final String EXTRA_SHOW_CHRONOMETER
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)
.
Constant Value: "android.showChronometer"
EXTRA_SHOW_WHEN
public static final String EXTRA_SHOW_WHEN
extras
key: whether the when field set using NotificationCompat.Builder.setWhen(long)
should be shown, as supplied to NotificationCompat.Builder.setShowWhen(boolean)
.
Constant Value: "android.showWhen"
EXTRA_SMALL_ICON
public static final String EXTRA_SMALL_ICON
extras
key: this is the resource ID of the notification's main small icon,
as supplied to NotificationCompat.Builder.setSmallIcon(int)
.
Constant Value: "android.icon"
EXTRA_SUB_TEXT
public static final String EXTRA_SUB_TEXT
extras
key: this is a third line of text, as supplied to
NotificationCompat.Builder.setSubText(CharSequence)
.
Constant Value: "android.subText"
EXTRA_SUMMARY_TEXT
public static final String EXTRA_SUMMARY_TEXT
extras
key: this is a line of summary information intended to be shown
alongside expanded notifications, as supplied to (e.g.)
NotificationCompat.BigTextStyle.setSummaryText(CharSequence)
.
Constant Value: "android.summaryText"
EXTRA_TEMPLATE
public static final String EXTRA_TEMPLATE
extras
key: A string representing the name of the specific
Notification.Style
used to create this notification.
Constant Value: "android.template"
EXTRA_TEXT
public static final String EXTRA_TEXT
extras
key: this is the main text payload, as supplied to
NotificationCompat.Builder.setContentText(CharSequence)
.
Constant Value: "android.text"
EXTRA_TEXT_LINES
public static final String EXTRA_TEXT_LINES
extras
key: An array of CharSequences to show in NotificationCompat.InboxStyle
expanded notifications, each of which was supplied to
NotificationCompat.InboxStyle.addLine(CharSequence)
.
Constant Value: "android.textLines"
EXTRA_TITLE
public static final String EXTRA_TITLE
extras
key: this is the title of the notification,
as supplied to NotificationCompat.Builder.setContentTitle(CharSequence)
.
Constant Value: "android.title"
EXTRA_TITLE_BIG
public static final String EXTRA_TITLE_BIG
extras
key: this is the title of the notification when shown in expanded
form, e.g. as supplied to NotificationCompat.BigTextStyle.setBigContentTitle(CharSequence)
.
Constant Value: "android.title.big"
FLAG_AUTO_CANCEL
public static final int FLAG_AUTO_CANCEL
Bit set in the Notification flags field if the notification should be canceled when it is clicked by the user.
Constant Value: 16 (0x00000010)
FLAG_BUBBLE
public static final int FLAG_BUBBLE
Bit set in the Notification flags field if this notification is showing as a bubble.
Applications cannot set this flag directly; they should instead call
NotificationCompat.Builder.setBubbleMetadata(BubbleMetadata)
to request that a
notification be displayed as a bubble, and then check this flag to see whether that request
was honored by the system.
Constant Value: 4096 (0x00001000)
FLAG_FOREGROUND_SERVICE
public static final int FLAG_FOREGROUND_SERVICE
Bit set in the Notification flags field if this notification represents a currently
running service. This will normally be set for you by
Service.startForeground(int, Notification)
.
Constant Value: 64 (0x00000040)
FLAG_GROUP_SUMMARY
public static final int FLAG_GROUP_SUMMARY
Bit set in the Notification flags field if this notification is the group summary for a
group of notifications. Grouped notifications may display in a cluster or stack on devices
which support such rendering. Requires a group key also be set using
NotificationCompat.Builder.setGroup(String)
.
Constant Value: 512 (0x00000200)
FLAG_HIGH_PRIORITY
public static final int FLAG_HIGH_PRIORITY
This constant is deprecated.
Use NotificationCompat.Builder.setPriority(int)
with a positive value.
Obsolete flag indicating high-priority notifications; use the priority field instead.
Constant Value: 128 (0x00000080)
FLAG_INSISTENT
public static final 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.
Constant Value: 4 (0x00000004)
FLAG_LOCAL_ONLY
public static final 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.
Constant Value: 256 (0x00000100)
FLAG_NO_CLEAR
public static final 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.
Constant Value: 32 (0x00000020)
FLAG_ONGOING_EVENT
public static final 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. It should not be set if this notification is in reference to something that happened at a particular point in time, like a missed phone call.
Constant Value: 2 (0x00000002)
FLAG_ONLY_ALERT_ONCE
public static final 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.
Constant Value: 8 (0x00000008)
FLAG_SHOW_LIGHTS
public static final int FLAG_SHOW_LIGHTS
Bit set in the Notification flags field when LEDs should be turned on for this notification.
Constant Value: 1 (0x00000001)
GROUP_ALERT_ALL
public static final int GROUP_ALERT_ALL
Constant for NotificationCompat.Builder.setGroupAlertBehavior(int)
, meaning that all notifications in a
group with sound or vibration ought to make sound or vibrate (respectively), so this
notification will not be muted when it is in a group.
Constant Value: 0 (0x00000000)
GROUP_ALERT_CHILDREN
public static final int GROUP_ALERT_CHILDREN
Constant for NotificationCompat.Builder.setGroupAlertBehavior(int)
, meaning that the summary
notification in a group should be silenced (no sound or vibration) even if they would
otherwise make sound or vibrate. Use this constant
to mute this notification if this notification is a group summary.
For example, you might want to use this constant if only the children notifications in your group have content and the summary is only used to visually group notifications rather than to alert the user that new information is available.
Constant Value: 2 (0x00000002)
GROUP_ALERT_SUMMARY
public static final int GROUP_ALERT_SUMMARY
Constant for NotificationCompat.Builder.setGroupAlertBehavior(int)
, meaning that all children
notification in a group should be silenced (no sound or vibration) even if they would
otherwise make sound or vibrate. Use this constant to mute this notification if this
notification is a group child. This must be applied to all children notifications you want
to mute.
For example, you might want to use this constant if you post a number of children notifications at once (say, after a periodic sync), and only need to notify the user audibly once.
Constant Value: 1 (0x00000001)
GROUP_KEY_SILENT
public static final String GROUP_KEY_SILENT
Constant for the group key
that's added to notifications
that are not already grouped when NotificationCompat.Builder.setNotificationSilent()
is used when
Build.VERSION.SDK_INT
is >= Build.VERSION_CODES.O
.
Constant Value: "silent"
INTENT_CATEGORY_NOTIFICATION_PREFERENCES
public static final String INTENT_CATEGORY_NOTIFICATION_PREFERENCES
An activity that provides a user interface for adjusting notification preferences for its containing application.
Constant Value: "android.intent.category.NOTIFICATION_PREFERENCES"
PRIORITY_DEFAULT
public static final int PRIORITY_DEFAULT
Default notification priority for NotificationCompat.Builder.setPriority(int)
.
If your application does not prioritize its own notifications,
use this value for all notifications.
Constant Value: 0 (0x00000000)
PRIORITY_HIGH
public static final int PRIORITY_HIGH
Higher notification priority for 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.
Constant Value: 1 (0x00000001)
PRIORITY_LOW
public static final int PRIORITY_LOW
Lower notification priority for 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.
Constant Value: -1 (0xffffffff)
PRIORITY_MAX
public static final 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.
Constant Value: 2 (0x00000002)
PRIORITY_MIN
public static final 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.
Constant Value: -2 (0xfffffffe)
STREAM_DEFAULT
public static final int STREAM_DEFAULT
Use this constant as the value for audioStreamType to request that
the default stream type for notifications be used. Currently the
default stream type is AudioManager.STREAM_NOTIFICATION
.
Constant Value: -1 (0xffffffff)
VISIBILITY_PRIVATE
public static final int VISIBILITY_PRIVATE
Notification visibility: Show this notification on all lockscreens, but conceal sensitive or private information on secure lockscreens.
See also:
Constant Value: 0 (0x00000000)
VISIBILITY_PUBLIC
public static final int VISIBILITY_PUBLIC
Notification visibility: Show this notification in its entirety on all lockscreens.
See also:
Constant Value: 1 (0x00000001)
VISIBILITY_SECRET
public static final int VISIBILITY_SECRET
Notification visibility: Do not reveal any part of this notification on a secure lockscreen.
See also:
Constant Value: -1 (0xffffffff)
Public constructors
NotificationCompat
public NotificationCompat ()
This constructor is deprecated.
This type should not be instantiated as it contains only static methods.
Public methods
getAction
public static NotificationCompat.Action getAction (Notification notification, int actionIndex)
Get an action on this notification in a backwards compatible manner. Actions were supported from JellyBean (Api level 16) forwards.
Parameters | |
---|---|
notification |
Notification : The notification to inspect. |
actionIndex |
int : The index of the action to retrieve.
|
Returns | |
---|---|
NotificationCompat.Action |
getActionCount
public static int getActionCount (Notification notification)
Get the number of actions in this notification in a backwards compatible manner. Actions were supported from JellyBean (Api level 16) forwards.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
int |
getAllowSystemGeneratedContextualActions
public static boolean getAllowSystemGeneratedContextualActions (Notification notification)
Returns whether the platform is allowed (by the app developer) to generate contextual actions for this notification.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
boolean |
getAutoCancel
public static boolean getAutoCancel (Notification notification)
Get the value provided to NotificationCompat.Builder.setAutoCancel(boolean)
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
boolean |
getBadgeIconType
public static int getBadgeIconType (Notification notification)
Returns what icon should be shown for this notification if it is being displayed in a
Launcher that supports badging. Will be one of BADGE_ICON_NONE
,
BADGE_ICON_SMALL
, or BADGE_ICON_LARGE
.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
int |
getBubbleMetadata
public static NotificationCompat.BubbleMetadata getBubbleMetadata (Notification notification)
Get the NotificationCompat.BubbleMetadata
for a notification that will be used to display app content in
a floating window over the existing foreground activity.
Parameters | |
---|---|
notification |
Notification : the notification to inspect |
Returns | |
---|---|
NotificationCompat.BubbleMetadata |
the BubbleMetadata if available and set, otherwise null |
getCategory
public static String getCategory (Notification notification)
Get the category of this notification in a backwards compatible manner.
Parameters | |
---|---|
notification |
Notification : The notification to inspect.
|
Returns | |
---|---|
String |
getChannelId
public static String getChannelId (Notification notification)
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
String |
the ID of the channel this notification posts to. |
getColor
public static int getColor (Notification notification)
Get the value provided to NotificationCompat.Builder.setColor(int)
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
int |
getContentInfo
public static CharSequence getContentInfo (Notification notification)
Returns the content info provided to NotificationCompat.Builder.setContentInfo(CharSequence)
.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
CharSequence |
getContentText
public static CharSequence getContentText (Notification notification)
Returns the content text provided to NotificationCompat.Builder.setContentText(CharSequence)
.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
CharSequence |
getContentTitle
public static CharSequence getContentTitle (Notification notification)
Returns the content title provided to NotificationCompat.Builder.setContentTitle(CharSequence)
.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
CharSequence |
getExtras
public static Bundle getExtras (Notification notification)
Gets the 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.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
Bundle |
getGroup
public static String getGroup (Notification notification)
Get the key used to group this notification into a cluster or stack with other notifications on devices which support such rendering.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
String |
getGroupAlertBehavior
public static int getGroupAlertBehavior (Notification notification)
Returns which type of notifications in a group are responsible for audibly alerting the
user. See GROUP_ALERT_ALL
, GROUP_ALERT_CHILDREN
,
GROUP_ALERT_SUMMARY
.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
int |
getInvisibleActions
public static List<NotificationCompat.Action> getInvisibleActions (Notification notification)
Returns the invisible actions contained within the given notification.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
List<NotificationCompat.Action> |
getLocalOnly
public static boolean getLocalOnly (Notification notification)
Get whether or not this notification is only relevant to the current device.
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.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
boolean |
getLocusId
public static LocusIdCompat getLocusId (Notification notification)
Gets the LocusIdCompat
associated with this notification.
Used by the Android system to correlate objects (such as
ShortcutInfoCompat
and
ContentCaptureContext
).
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
LocusIdCompat |
getOngoing
public static boolean getOngoing (Notification notification)
Get the value provided to NotificationCompat.Builder.setOngoing(boolean)
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
boolean |
getOnlyAlertOnce
public static boolean getOnlyAlertOnce (Notification notification)
Get the value provided to NotificationCompat.Builder.setOnlyAlertOnce(boolean)
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
boolean |
getPeople
public static List<Person> getPeople (Notification notification)
Returns the people in the notification.
On platforms which do not have the Person
class, the
Person
objects will contain only the URI from NotificationCompat.Builder.addPerson(String)
.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
List<Person> |
getPublicVersion
public static Notification getPublicVersion (Notification notification)
Get the value provided to NotificationCompat.Builder.setVisibility(int)
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
Notification |
getSettingsText
public static CharSequence getSettingsText (Notification notification)
Returns the settings text provided to NotificationCompat.Builder.setSettingsText(CharSequence)
.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
CharSequence |
getShortcutId
public static String getShortcutId (Notification notification)
Returns the id
that this
notification supersedes, if any.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
String |
getShowWhen
public static boolean getShowWhen (Notification notification)
Get the value provided to NotificationCompat.Builder.setShowWhen(boolean)
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
boolean |
getSortKey
public static String getSortKey (Notification notification)
Get a sort key that orders this notification among other notifications from the same package. This can be useful if an external sort was already applied and an app would like to preserve this. Notifications will be sorted lexicographically using this value, although providing different priorities in addition to providing sort key may cause this value to be ignored.
This sort key can also be used to order members of a notification group. See
NotificationCompat.Builder.setGroup(String)
.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
String |
See also:
getSubText
public static CharSequence getSubText (Notification notification)
Returns the sub text provided to NotificationCompat.Builder.setSubText(CharSequence)
.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
CharSequence |
getTimeoutAfter
public static long getTimeoutAfter (Notification notification)
Returns the time at which this notification should be canceled by the system, if it's not canceled already.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
long |
getUsesChronometer
public static boolean getUsesChronometer (Notification notification)
Get the value provided to NotificationCompat.Builder.setUsesChronometer(boolean)
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
boolean |
getVisibility
public static int getVisibility (Notification notification)
Get the value provided to NotificationCompat.Builder.setVisibility(int)
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
int |
isGroupSummary
public static boolean isGroupSummary (Notification notification)
Get whether this notification to be the group summary for a group of notifications.
Grouped notifications may display in a cluster or stack on devices which
support such rendering. Requires a group key also be set using NotificationCompat.Builder.setGroup(String)
.
Parameters | |
---|---|
notification |
Notification |
Returns | |
---|---|
boolean |
Whether this notification is a group summary. |
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-02-24 UTC.