Notification | API reference | Android Developers (original) (raw)
public class Notificationextends [Object](/reference/java/lang/Object) implements[Parcelable](/reference/android/os/Parcelable)
A class that represents how a persistent notification is to be presented to the user using the [NotificationManager](/reference/android/app/NotificationManager).
The [Notification.Builder](/reference/android/app/Notification.Builder) has been added to make it easier to construct Notifications.
Summary
| Nested classes | |
|---|---|
| class | Notification.Action Structure to encapsulate a named action that can be shown as part of this notification. |
| class | Notification.BigPictureStyle Helper class for generating large-format notifications that include a large image attachment. |
| class | Notification.BigTextStyle Helper class for generating large-format notifications that include a lot of text. |
| class | Notification.BridgedNotificationMetadata Encapsulates the information needed to display a notification as a bridged notification. |
| class | Notification.BubbleMetadata Encapsulates the information needed to display a notification as a bubble. |
| class | Notification.Builder Builder class for Notification objects. |
| class | Notification.CallStyle Helper class for generating large-format notifications that include a caller and required actions, such as an incoming call with answer / decline. |
| class | Notification.CarExtender Helper class to add Android Auto extensions to notifications. |
| class | Notification.DecoratedCustomViewStyle Notification style for custom views that are decorated by the systemInstead of providing a notification that is completely custom, a developer can set this style and still obtain system decorations like the notification header with the expand affordance and actions. |
| class | Notification.DecoratedMediaCustomViewStyle Notification style for media custom views that are decorated by the systemInstead of providing a media notification that is completely custom, a developer can set this style and still obtain system decorations like the notification header with the expand affordance and actions. |
| interface | Notification.Extender Extender interface for use with Builder.extend. |
| class | Notification.InboxStyle Helper class for generating large-format notifications that include a list of (up to 5) strings. |
| class | Notification.MediaStyle Notification style for media playback notifications. |
| class | Notification.MessagingStyle Helper class for generating large-format notifications that include multiple back-and-forth messages of varying types between any number of people. |
| class | Notification.Metric A metric, used with MetricStyle, and which has a value and a label. |
| class | Notification.MetricStyle A notification style which shows up to 3 metrics when expanded. |
| class | Notification.ProgressStyle A Notification Style used to define a notification whose expanded state includes a highly customizable progress bar with segments, points, a custom tracker icon, and custom icons at the start and end of the progress bar. |
| class | Notification.ProjectedExtender Helper class to add projection-specific extensions to a notification. |
| class | Notification.Style An object that can apply a rich notification style to a Notification.Builder object. |
| class | Notification.TvExtender Helper class to add Android TV extensions to notifications. |
| class | Notification.WearableExtender Helper class to add wearable extensions to notifications. |
| Constants | |
|---|---|
| String | ACTION_BRIDGED_NOTIFICATION_PREFERENCES An activity that provides a user interface for adjusting notification preferences for its bridged notification which originated on another device. |
| int | BADGE_ICON_LARGE If this notification is being shown as a badge, use the getLargeIcon() to represent this notification. |
| 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 getSmallIcon() to represent this notification. |
| 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_VOICEMAIL Notification category: voicemail. |
| String | CATEGORY_WORKOUT Notification category: tracking a user's workout. |
| int | COLOR_DEFAULT Special value of color telling the system not to decorate this element with any special color (but instead use default system colors). |
| 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_ANSWER_COLOR extras key: the color used as a hint for the Answer action button of aNotification.CallStyle notification. |
| String | EXTRA_ANSWER_INTENT extras key: the intent to be sent when the users answers aNotification.CallStyle notification. |
| String | EXTRA_AUDIO_CONTENTS_URI extras key: the audio contents of this notification. |
| String | EXTRA_BACKGROUND_IMAGE_URI extras key: flat String representation of a content URI pointing to an image that can be displayed in the background when the notification is selected. |
| String | EXTRA_BIG_TEXT extras key: this is the longer text shown in the expanded form of aBigTextStyle notification, as supplied toBigTextStyle.bigText(CharSequence). |
| String | EXTRA_CALL_IS_VIDEO extras key: whether the Notification.CallStyle notification is for a call that will activate video when answered. |
| String | EXTRA_CALL_PERSON extras key: the person to be displayed as calling for theNotification.CallStyle notification. |
| String | EXTRA_CALL_TYPE extras key: the type of call represented by theNotification.CallStyle notification. |
| String | EXTRA_CHANNEL_GROUP_ID Optional extra for INTENT_CATEGORY_NOTIFICATION_PREFERENCES. |
| String | EXTRA_CHANNEL_ID Optional extra for INTENT_CATEGORY_NOTIFICATION_PREFERENCES. |
| String | EXTRA_CHRONOMETER_COUNT_DOWN extras key: whether the chronometer set on the notification should count down instead of counting up. |
| String | EXTRA_COLORIZED extras key: whether the notification should be colorized as supplied to Builder.setColorized(boolean). |
| String | EXTRA_COMPACT_ACTIONS extras key: the indices of actions to be shown in the compact view, as supplied to (e.g.) MediaStyle.setShowActionsInCompactView(int...). |
| String | EXTRA_CONVERSATION_TITLE extras key: a CharSequence to be displayed as the title to a conversation represented by a Notification.MessagingStyle |
| String | EXTRA_DECLINE_COLOR extras key: the color used as a hint for the Decline or Hang Up action button of aNotification.CallStyle notification. |
| String | EXTRA_DECLINE_INTENT extras key: the intent to be sent when the users declines aNotification.CallStyle notification. |
| String | EXTRA_HANG_UP_INTENT extras key: the intent to be sent when the users hangs up aNotification.CallStyle notification. |
| String | EXTRA_HISTORIC_MESSAGES extras key: an array ofhistoric Notification.MessagingStyle.Message bundles provided by aNotification.MessagingStyle notification. |
| String | EXTRA_INFO_TEXT extras key: this is a small piece of additional text as supplied toBuilder.setContentInfo(CharSequence). |
| String | EXTRA_IS_GROUP_CONVERSATION extras key: whether the Notification.MessagingStyle notification represents a group conversation. |
| String | EXTRA_LARGE_ICON This constant was deprecated in API level 26. Use getLargeIcon(), which supports a wider variety of icon sources. |
| String | EXTRA_LARGE_ICON_BIG extras key: this is a bitmap to be used instead of the one fromBuilder.setLargeIcon(android.graphics.Bitmap) when the notification is shown in its expanded form, as supplied toBigPictureStyle.bigLargeIcon(android.graphics.Bitmap). |
| String | EXTRA_MEDIA_SESSION extras key: AMediaSession.Token associated with aNotification.MediaStyle notification. |
| String | EXTRA_MESSAGES extras key: an array of Notification.MessagingStyle.Message bundles provided by aNotification.MessagingStyle notification. |
| String | EXTRA_MESSAGING_PERSON extras key: the person to be displayed for all messages sent by the user including direct repliesNotification.MessagingStyle notification. |
| String | EXTRA_NOTIFICATION_ID Optional extra for INTENT_CATEGORY_NOTIFICATION_PREFERENCES. |
| String | EXTRA_NOTIFICATION_TAG Optional extra for INTENT_CATEGORY_NOTIFICATION_PREFERENCES. |
| String | EXTRA_PEOPLE This constant was deprecated in API level 28. the actual objects are now in EXTRA_PEOPLE_LIST |
| String | EXTRA_PEOPLE_LIST extras key: An arrayList of Person objects containing the people that this notification relates to. |
| String | EXTRA_PICTURE extras key: this is a bitmap to be shown in BigPictureStyle expanded notifications, supplied to BigPictureStyle.bigPicture(android.graphics.Bitmap). |
| String | EXTRA_PICTURE_CONTENT_DESCRIPTION extras key: this is a content description of the big picture supplied fromBigPictureStyle.bigPicture(Bitmap), supplied toBigPictureStyle.setContentDescription(CharSequence). |
| String | EXTRA_PICTURE_ICON extras key: this is an Icon of an image to be shown in BigPictureStyle expanded notifications, supplied toBigPictureStyle.bigPicture(Icon). |
| String | EXTRA_PREFER_SMALL_ICON A boolean for extras requesting that the notification card show the small icon instead of the launcher app icon. |
| String | EXTRA_PROGRESS extras key: this is the progress value supplied toBuilder.setProgress(int,int,boolean). |
| String | EXTRA_PROGRESS_INDETERMINATE extras key: whether the progress bar is indeterminate, supplied toBuilder.setProgress(int,int,boolean). |
| String | EXTRA_PROGRESS_MAX extras key: this is the maximum value supplied toBuilder.setProgress(int,int,boolean). |
| String | EXTRA_REMOTE_INPUT_DRAFT If the notification contained an unsent draft for a RemoteInput when the user clicked on it, we're adding the draft as a String extra to the contentIntent using this key. |
| String | EXTRA_REMOTE_INPUT_HISTORY extras key: this is the remote input history, as supplied toBuilder.setRemoteInputHistory(CharSequence[]). |
| String | EXTRA_REQUEST_PROMOTED_ONGOING extras key: If provided, should contain a boolean indicating whether the notification is requesting promoted treatment. |
| String | EXTRA_SELF_DISPLAY_NAME This constant was deprecated in API level 28. use EXTRA_MESSAGING_PERSON |
| String | EXTRA_SHOW_BIG_PICTURE_WHEN_COLLAPSED extras key: this is a boolean to indicate that thebig picture is to be shown in the collapsed state of a BigPictureStyle notification. |
| String | EXTRA_SHOW_CHRONOMETER extras key: whether when should be shown as a count-up timer (specifically a Chronometer) instead of a timestamp, as supplied toBuilder.setUsesChronometer(boolean). |
| String | EXTRA_SHOW_WHEN extras key: whether when should be shown, as supplied to Builder.setShowWhen(boolean). |
| String | EXTRA_SMALL_ICON This constant was deprecated in API level 26. Use getSmallIcon(), which supports a wider variety of icon sources. |
| String | EXTRA_SUB_TEXT extras key: this is a third line of text, as supplied toBuilder.setSubText(CharSequence). |
| 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.)BigTextStyle.setSummaryText(CharSequence). |
| String | EXTRA_TEMPLATE extras key: A string representing the name of the specificNotification.Style used to create this notification. |
| String | EXTRA_TEXT extras key: this is the main text payload, as supplied toBuilder.setContentText(CharSequence). |
| String | EXTRA_TEXT_LINES extras key: An array of CharSequences to show in InboxStyle expanded notifications, each of which was supplied to InboxStyle.addLine(CharSequence). |
| String | EXTRA_TITLE extras key: this is the title of the notification, as supplied to Builder.setContentTitle(CharSequence). |
| String | EXTRA_TITLE_BIG extras key: this is the title of the notification when shown in expanded form, e.g. as supplied to BigTextStyle.setBigContentTitle(CharSequence). |
| String | EXTRA_VERIFICATION_ICON extras key: the icon to be displayed as a verification status of the caller on aNotification.CallStyle notification. |
| String | EXTRA_VERIFICATION_TEXT extras key: the text to be displayed as a verification status of the caller on aNotification.CallStyle notification. |
| int | FLAG_AUTO_CANCEL Bit to be bitwise-ORed into the flags field that should be set if the notification should be canceled when it is clicked by the user. |
| int | FLAG_BUBBLE Bit to be bitwise-ORed into the flags field that should be set by the system if this notification is showing as a bubble. |
| int | FLAG_FOREGROUND_SERVICE Bit to be bitwise-ORed into the flags field that should be set if this notification represents a currently running service. |
| int | FLAG_GROUP_SUMMARY Bit to be bitwise-ORed into the flags field that should be set if this notification is the group summary for a group of notifications. |
| int | FLAG_HIGH_PRIORITY This constant was deprecated in API level 16. Use priority with a positive value. |
| int | FLAG_INSISTENT Bit to be bitwise-ORed into the flags field that if set, the audio will be repeated until the notification is cancelled or the notification window is opened. |
| int | FLAG_LOCAL_ONLY Bit to be bitwise-ORed into the flags field that should be set 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 to be bitwise-ORed into the flags field that should be set if the notification should not be canceled when the user clicks the Clear all button. |
| int | FLAG_ONGOING_EVENT Bit to be bitwise-ORed into the flags field that should be set if this notification is in reference to something that is ongoing, like a phone call. |
| int | FLAG_ONLY_ALERT_ONCE Bit to be bitwise-ORed into the flags field that should be set if you would only like the sound, vibrate and ticker to be played if the notification was not already showing. |
| int | FLAG_PROMOTED_ONGOING Bit to be bitwise-ORed into the flags field that should be set by the system if this notification is a promoted ongoing notification, both because ithasPromotableCharacteristics() and the user has not disabled the feature for this app. |
| int | FLAG_SHOW_LIGHTS This constant was deprecated in API level 26. use NotificationChannel.shouldShowLights(). |
| int | FOREGROUND_SERVICE_DEFAULT If the Notification associated with starting a foreground service has been built usingNotification.Builder.setForegroundServiceBehavior(int) with this behavior, display of the notification will usually be suppressed for a short time to avoid visual disturbances to the user. |
| int | FOREGROUND_SERVICE_DEFERRED If the Notification associated with starting a foreground service has been built usingNotification.Builder.setForegroundServiceBehavior(int) with this behavior, display of the notification will usually be suppressed for a short time to avoid visual disturbances to the user. |
| int | FOREGROUND_SERVICE_IMMEDIATE If the Notification associated with starting a foreground service has been built usingNotification.Builder.setForegroundServiceBehavior(int) with this behavior, display of the notification will be immediate even if the default behavior would be to defer visibility for a short time. |
| int | GROUP_ALERT_ALL Constant for 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. |
| int | GROUP_ALERT_CHILDREN Constant for Builder.setGroupAlertBehavior(int), meaning that the summary notification in a group should be silenced (no sound or vibration) even if they are posted to a NotificationChannel that has sound and/or vibration. |
| int | GROUP_ALERT_SUMMARY Constant for Builder.setGroupAlertBehavior(int), meaning that all children notification in a group should be silenced (no sound or vibration) even if they are posted to a NotificationChannel that has sound and/or vibration. |
| String | INTENT_CATEGORY_NOTIFICATION_PREFERENCES An activity that provides a user interface for adjusting notification preferences for its containing application. |
| int | PRIORITY_DEFAULT This constant was deprecated in API level 26. use NotificationManager.IMPORTANCE_DEFAULT instead. |
| int | PRIORITY_HIGH This constant was deprecated in API level 26. use NotificationManager.IMPORTANCE_HIGH instead. |
| int | PRIORITY_LOW This constant was deprecated in API level 26. use NotificationManager.IMPORTANCE_LOW instead. |
| int | PRIORITY_MAX This constant was deprecated in API level 26. use NotificationManager.IMPORTANCE_HIGH instead. |
| int | PRIORITY_MIN This constant was deprecated in API level 26. use NotificationManager.IMPORTANCE_MIN instead. |
| int | SEMANTIC_STYLE_CAUTION This value is used to annotate an element as indicating caution, moderate urgency, tardiness, or another \u201cintermediate\u201d value on the semantic hierarchy. |
| int | SEMANTIC_STYLE_DANGER This value is used to annotate an element as indicating danger, extreme urgency or lateness, or another \u201cextreme\u201d value on the semantic hierarchy. |
| int | SEMANTIC_STYLE_INFO This value is used to annotate an element as indicating information that should stand out from other content, but which doesn\u2019t fall on a scale or hierarchy. |
| int | SEMANTIC_STYLE_SAFE This value is used to annotate an element as indicating safety, non-urgency, timeliness, or another \u201cmild\u201d value on the semantic hierarchy. |
| int | SEMANTIC_STYLE_UNSPECIFIED This is the default value for semantic style, signaling no particular semantics. |
| int | STREAM_DEFAULT This constant was deprecated in API level 21. Use NotificationChannel.getAudioAttributes() instead. |
| 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 and while screen sharing. |
| int | VISIBILITY_SECRET Notification visibility: Do not reveal any part of this notification on a secure lockscreen or while screen sharing. |
| Inherited constants |
|---|
| From interfaceandroid.os.Parcelable int CONTENTS_FILE_DESCRIPTOR Descriptor bit used with describeContents(): indicates that the Parcelable object's flattened representation includes a file descriptor. int PARCELABLE_WRITE_RETURN_VALUE Flag for use with writeToParcel(Parcel, int): the object being written is a return value, that is the result of a function such as "Parcelable someFunction()", "void someFunction(out Parcelable)", or "void someFunction(inout Parcelable)". |
| Fields | |
|---|---|
| public static finalAudioAttributes | AUDIO_ATTRIBUTES_DEFAULT The default value of audioAttributes. |
| public static finalCreator<Notification> | CREATOR Parcelable.Creator that instantiates Notification objects |
| publicAction[] | actions Array of all Action structures attached to this notification byBuilder.addAction(int,CharSequence,PendingIntent). |
| publicAudioAttributes | audioAttributes This field was deprecated in API level 26. use NotificationChannel.getAudioAttributes() instead. |
| public int | audioStreamType This field was deprecated in API level 21. Use audioAttributes instead. |
| publicRemoteViews | bigContentView A large-format version of contentView, giving the Notification an opportunity to show more detail when expanded. |
| publicString | category One of the predefined notification categories (see the CATEGORY_* constants) that best describes this Notification. |
| public int | color Accent color (an ARGB integer like the constants in Color) to be applied by the standard Style templates when presenting this notification. |
| publicPendingIntent | contentIntent The intent to execute when the expanded status entry is clicked. |
| publicRemoteViews | contentView The view that will represent this notification in the notification list (which is pulled down from the status bar). |
| public int | defaults This field was deprecated in API level 26. use NotificationChannel.getSound() andNotificationChannel.shouldShowLights() andNotificationChannel.shouldVibrate(). |
| publicPendingIntent | deleteIntent The intent to execute when the notification is explicitly dismissed by the user, either with the "Clear All" button or by swiping it away individually. |
| publicBundle | extras Additional semantic data to be carried around with this Notification. |
| public int | flags |
| publicPendingIntent | fullScreenIntent An intent to launch instead of posting the notification to the status bar. |
| publicRemoteViews | headsUpContentView A medium-format version of contentView, providing the Notification an opportunity to add action buttons to contentView. |
| public int | icon This field was deprecated in API level 23. Use Builder.setSmallIcon(Icon) instead. |
| public int | iconLevel If the icon in the status bar is to have more than one level, you can set this. |
| publicBitmap | largeIcon This field was deprecated in API level 23. Use Builder.setLargeIcon(Icon) instead. |
| public int | ledARGB This field was deprecated in API level 26. use NotificationChannel.shouldShowLights(). |
| public int | ledOffMS This field was deprecated in API level 26. use NotificationChannel.shouldShowLights(). |
| public int | ledOnMS This field was deprecated in API level 26. use NotificationChannel.shouldShowLights(). |
| public int | number The number of events that this notification represents. |
| public int | priority This field was deprecated in API level 26. use NotificationChannel.getImportance() instead. |
| publicNotification | publicVersion Replacement version of this notification whose content will be shown in an insecure context such as atop a secure keyguard. |
| publicUri | sound This field was deprecated in API level 26. use NotificationChannel.getSound(). |
| publicCharSequence | tickerText Text that summarizes this notification for accessibility services. |
| publicRemoteViews | tickerView Formerly, a view showing the tickerText. |
| public long[] | vibrate This field was deprecated in API level 26. use NotificationChannel.getVibrationPattern(). |
| public int | visibility Sphere of visibility of this notification, which affects how and when the SystemUI reveals the notification's presence and contents in untrusted situations (namely, on the secure lockscreen and during screen sharing). |
| public long | when A timestamp related to this notification, in milliseconds since the epoch. |
| Public constructors |
|---|
| Notification() Constructs a Notification object with default values. |
| Notification(Parcel parcel) Unflatten the notification from a parcel. |
| Notification(int icon, CharSequence tickerText, long when) This constructor is deprecated. Use Builder instead. |
| Public methods | |
|---|---|
| Notification | clone() Creates and returns a copy of this object. |
| staticAnnotation | createSemanticStyleAnnotation(int semanticStyle) Constructs an Annotation that can be used to span text in a Spanned CharSequence in some Notification text fields, and which may then be converted into styling of that section of text in order to indicate the semantic style. |
| int | describeContents() Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| Pair<RemoteInput, Notification.Action> | findRemoteInputActionPair(boolean requiresFreeform) Finds and returns a remote input and its corresponding action. |
| boolean | getAllowSystemGeneratedContextualActions() Returns whether the platform is allowed (by the app developer) to generate contextual actions for this notification. |
| int | getBadgeIconType() Returns what icon should be shown for this notification if it is being displayed in a Launcher that supports badging. |
| Notification.BridgedNotificationMetadata | getBridgedNotificationMetadata() Returns the metadata associated with a notification originating on another device. |
| Notification.BubbleMetadata | getBubbleMetadata() Returns the bubble metadata that will be used to display app content in a floating window over the existing foreground activity. |
| String | getChannelId() Returns the id of the channel this notification posts to. |
| List<Notification.Action> | getContextualActions() Returns the actions that are contextual (that is, suggested because of the content of the notification) out of the actions in this notification. |
| String | getGroup() Get the key used to group this notification into a cluster or stack with other notifications on devices which support such rendering. |
| int | getGroupAlertBehavior() Returns which type of notifications in a group are responsible for audibly alerting the user. |
| Icon | getLargeIcon() The large icon shown in this notification's content view. |
| LocusId | getLocusId() Gets the LocusId associated with this notification. |
| CharSequence | getSettingsText() Returns the settings text provided to Builder.setSettingsText(CharSequence). |
| String | getShortCriticalText() Returns the very short text summarizing the most critical information contained in the notification, or null if this field was not set. |
| String | getShortcutId() Returns the id that this notification supersedes, if any. |
| Icon | getSmallIcon() The small icon representing this notification in the status bar. |
| String | getSortKey() Get a sort key that orders this notification among other notifications from the same package. |
| long | getTimeoutAfter() Returns the duration from posting after which this notification should be canceled by the system, if it's not canceled already. |
| boolean | hasImage() |
| boolean | hasPromotableCharacteristics() Returns whether the notification has all the characteristics that make it eligible forFLAG_PROMOTED_ONGOING. |
| boolean | hasSummarizedContent() Returns whether this notification contains computationally summarized text. |
| boolean | isRequestPromotedOngoing() Returns whether this notification has requested to be a promoted ongoing notification. |
| String | toString() Returns a string representation of the object. |
| void | writeToParcel(Parcel parcel, int flags) Flatten this notification into a parcel. |
| Inherited methods |
|---|
| From class java.lang.Object Object clone() Creates and returns a copy of this object. boolean equals(Object obj) Indicates whether some other object is "equal to" this one. void finalize() Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. finalClass<?> getClass() Returns the runtime class of this Object. int hashCode() Returns a hash code value for the object. final void notify() Wakes up a single thread that is waiting on this object's monitor. final void notifyAll() Wakes up all threads that are waiting on this object's monitor. String toString() Returns a string representation of the object. final void wait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. final void wait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. final void wait() Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
| From interface android.os.Parcelable abstract int describeContents() Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. abstract void writeToParcel(Parcel dest, int flags) Flatten this object in to a Parcel. |
Constants
ACTION_BRIDGED_NOTIFICATION_PREFERENCES
public static final String ACTION_BRIDGED_NOTIFICATION_PREFERENCES
An activity that provides a user interface for adjusting notification preferences for its bridged notification which originated on another device.
Constant Value: "android.app.action.BRIDGED_NOTIFICATION_PREFERENCES"
BADGE_ICON_LARGE
public static final int BADGE_ICON_LARGE
If this notification is being shown as a badge, use the [getLargeIcon()](/reference/android/app/Notification#getLargeIcon%28%29) 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 [getSmallIcon()](/reference/android/app/Notification#getSmallIcon%28%29) 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"
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_VOICEMAIL
public static final String CATEGORY_VOICEMAIL
Notification category: voicemail.
Constant Value: "voicemail"
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
Special value of [color](/reference/android/app/Notification#color) telling the system not to decorate this element with any special color (but instead use default system colors).
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](/reference/android/app/Notification#FLAG%5FSHOW%5FLIGHTS) bit, and [ledARGB](/reference/android/app/Notification#ledARGB), [ledOffMS](/reference/android/app/Notification#ledOffMS), or[ledOnMS](/reference/android/app/Notification#ledOnMS).
Constant Value: 4 (0x00000004)
DEFAULT_SOUND
public static final int DEFAULT_SOUND
Use the default notification sound. This will ignore any given[sound](/reference/android/app/Notification#sound).
A notification that is noisy is more likely to be presented as a heads-up notification.
Constant Value: 1 (0x00000001)
DEFAULT_VIBRATE
public static final int DEFAULT_VIBRATE
Use the default notification vibrate. This will ignore any given[vibrate](/reference/android/app/Notification#vibrate). Using phone vibration requires the[VIBRATE](/reference/android/Manifest.permission#VIBRATE) permission.
A notification that vibrates is more likely to be presented as a heads-up notification.
Constant Value: 2 (0x00000002)
public static final String EXTRA_ANSWER_COLOR
[extras](/reference/android/app/Notification#extras) key: the color used as a hint for the Answer action button of a[Notification.CallStyle](/reference/android/app/Notification.CallStyle) notification. This extra is a ColorInt.
Constant Value: "android.answerColor"
EXTRA_AUDIO_CONTENTS_URI
public static final String EXTRA_AUDIO_CONTENTS_URI
[extras](/reference/android/app/Notification#extras) key: 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](/reference/android/app/Notification.MessagingStyle) since each[MessagingStyle.Message](/reference/android/app/Notification.MessagingStyle.Message) has a field for holding data URI. That field can be used for audio. See [MessagingStyle.Message.setData](/reference/android/app/Notification.MessagingStyle.Message#setData%28java.lang.String,%20android.net.Uri%29).
Example usage:
Notification.Builder myBuilder = (build your Notification as normal); myBuilder.getExtras().putString(EXTRA_AUDIO_CONTENTS_URI, myAudioUri.toString());
Constant Value: "android.audioContents"
public static final String EXTRA_BACKGROUND_IMAGE_URI
[extras](/reference/android/app/Notification#extras) key: flat [String](/reference/java/lang/String) representation of a [content URI](/reference/android/content/ContentUris) pointing to an image that can be displayed in the background when the notification is selected. Used on television platforms. The URI must point to an image stream suitable for passing into [BitmapFactory.decodeStream](/reference/android/graphics/BitmapFactory#decodeStream%28java.io.InputStream%29); all other content types will be ignored.
Constant Value: "android.backgroundImageUri"
public static final String EXTRA_CALL_IS_VIDEO
[extras](/reference/android/app/Notification#extras) key: whether the [Notification.CallStyle](/reference/android/app/Notification.CallStyle) notification is for a call that will activate video when answered. This extra is a boolean.
Constant Value: "android.callIsVideo"
public static final String EXTRA_CALL_PERSON
[extras](/reference/android/app/Notification#extras) key: the person to be displayed as calling for the[Notification.CallStyle](/reference/android/app/Notification.CallStyle) notification. This extra is a [Person](/reference/android/app/Person).
Constant Value: "android.callPerson"
public static final String EXTRA_CALL_TYPE
[extras](/reference/android/app/Notification#extras) key: the type of call represented by the[Notification.CallStyle](/reference/android/app/Notification.CallStyle) notification. This extra is an int.
Constant Value: "android.callType"
public static final String EXTRA_CHANNEL_GROUP_ID
Optional extra for [INTENT_CATEGORY_NOTIFICATION_PREFERENCES](/reference/android/app/Notification#INTENT%5FCATEGORY%5FNOTIFICATION%5FPREFERENCES). If provided, will contain a [group id](/reference/android/app/NotificationChannelGroup#getId%28%29) that can be used to narrow down what settings should be shown in the target app.
Constant Value: "android.intent.extra.CHANNEL_GROUP_ID"
public static final String EXTRA_CHRONOMETER_COUNT_DOWN
[extras](/reference/android/app/Notification#extras) key: whether the chronometer set on the notification should count down instead of counting up. Is only relevant if key [EXTRA_SHOW_CHRONOMETER](/reference/android/app/Notification#EXTRA%5FSHOW%5FCHRONOMETER) is present. This extra is a boolean. The default is false.
Constant Value: "android.chronometerCountDown"
public static final String EXTRA_DECLINE_COLOR
[extras](/reference/android/app/Notification#extras) key: the color used as a hint for the Decline or Hang Up action button of a[Notification.CallStyle](/reference/android/app/Notification.CallStyle) notification. This extra is a ColorInt.
Constant Value: "android.declineColor"
public static final String EXTRA_IS_GROUP_CONVERSATION
[extras](/reference/android/app/Notification#extras) key: whether the [Notification.MessagingStyle](/reference/android/app/Notification.MessagingStyle) notification represents a group conversation.
Constant Value: "android.isGroupConversation"
public static final String EXTRA_LARGE_ICON
This constant was deprecated in API level 26.
Use [getLargeIcon()](/reference/android/app/Notification#getLargeIcon%28%29), which supports a wider variety of icon sources.
[extras](/reference/android/app/Notification#extras) key: this is a bitmap to be used instead of the small icon when showing the notification payload, as supplied to [Builder.setLargeIcon(android.graphics.Bitmap)](/reference/android/app/Notification.Builder#setLargeIcon%28android.graphics.Bitmap%29).
Constant Value: "android.largeIcon"
public static final String EXTRA_MESSAGING_PERSON
[extras](/reference/android/app/Notification#extras) key: the person to be displayed for all messages sent by the user including direct replies[Notification.MessagingStyle](/reference/android/app/Notification.MessagingStyle) notification. This extra is a[Person](/reference/android/app/Person).
Constant Value: "android.messagingUser"
public static final String EXTRA_PEOPLE
This constant was deprecated in API level 28.
the actual objects are now in [EXTRA_PEOPLE_LIST](/reference/android/app/Notification#EXTRA%5FPEOPLE%5FLIST)
[extras](/reference/android/app/Notification#extras) key: A String array containing the people that this notification relates to, each of which was supplied to [Builder.addPerson(String)](/reference/android/app/Notification.Builder#addPerson%28java.lang.String%29).
Constant Value: "android.people"
public static final String EXTRA_PEOPLE_LIST
[extras](/reference/android/app/Notification#extras) key: An arrayList of [Person](/reference/android/app/Person) objects containing the people that this notification relates to.
Constant Value: "android.people.list"
public static final String EXTRA_PREFER_SMALL_ICON
A boolean for [extras](/reference/android/app/Notification#extras) requesting that the notification card show the small icon instead of the launcher app icon.
Constant Value: "android.app.preferSmallIcon"
public static final String EXTRA_REMOTE_INPUT_DRAFT
If the notification contained an unsent draft for a RemoteInput when the user clicked on it, we're adding the draft as a String extra to the [contentIntent](/reference/android/app/Notification#contentIntent) using this key.
Apps may use this extra to prepopulate text fields in the app, where the user usually sends messages.
Constant Value: "android.remoteInputDraft"
public static final String EXTRA_REMOTE_INPUT_HISTORY
[extras](/reference/android/app/Notification#extras) key: this is the remote input history, as supplied to[Builder.setRemoteInputHistory(CharSequence[])](/reference/android/app/Notification.Builder#setRemoteInputHistory%28java.lang.CharSequence[]%29).
Apps can fill this through [Builder.setRemoteInputHistory(CharSequence[])](/reference/android/app/Notification.Builder#setRemoteInputHistory%28java.lang.CharSequence[]%29) with the most recent inputs that have been sent through a [RemoteInput](/reference/android/app/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"
public static final String EXTRA_REQUEST_PROMOTED_ONGOING
[extras](/reference/android/app/Notification#extras) key: If provided, should contain a boolean indicating whether the notification is requesting promoted treatment.
Constant Value: "android.requestPromotedOngoing"
public static final String EXTRA_SHOW_BIG_PICTURE_WHEN_COLLAPSED
[extras](/reference/android/app/Notification#extras) key: this is a boolean to indicate that the[big picture](/reference/android/app/Notification.BigPictureStyle#bigPicture%28android.graphics.Bitmap%29) is to be shown in the collapsed state of a [BigPictureStyle](/reference/android/app/Notification.BigPictureStyle) notification. This will replace a[large icon](/reference/android/app/Notification.Builder#setLargeIcon%28android.graphics.drawable.Icon%29) in that state if one was provided.
Constant Value: "android.showBigPictureWhenCollapsed"
public static final String EXTRA_SMALL_ICON
This constant was deprecated in API level 26.
Use [getSmallIcon()](/reference/android/app/Notification#getSmallIcon%28%29), which supports a wider variety of icon sources.
[extras](/reference/android/app/Notification#extras) key: this is the resource ID of the notification's main small icon, as supplied to [Builder.setSmallIcon(int)](/reference/android/app/Notification.Builder#setSmallIcon%28int%29).
Constant Value: "android.icon"
public static final String EXTRA_TEMPLATE
[extras](/reference/android/app/Notification#extras) key: A string representing the name of the specific[Notification.Style](/reference/android/app/Notification.Style) used to create this notification.
Constant Value: "android.template"
public static final String EXTRA_VERIFICATION_ICON
[extras](/reference/android/app/Notification#extras) key: the icon to be displayed as a verification status of the caller on a[Notification.CallStyle](/reference/android/app/Notification.CallStyle) notification. This extra is an [Icon](/reference/android/graphics/drawable/Icon).
Constant Value: "android.verificationIcon"
public static final String EXTRA_VERIFICATION_TEXT
[extras](/reference/android/app/Notification#extras) key: the text to be displayed as a verification status of the caller on a[Notification.CallStyle](/reference/android/app/Notification.CallStyle) notification. This extra is a[CharSequence](/reference/java/lang/CharSequence).
Constant Value: "android.verificationText"
FLAG_AUTO_CANCEL
public static final int FLAG_AUTO_CANCEL
Bit to be bitwise-ORed into the [flags](/reference/android/app/Notification#flags) field that should be set 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 to be bitwise-ORed into the [flags](/reference/android/app/Notification#flags) field that should be set by the system if this notification is showing as a bubble.
Applications cannot set this flag directly; they should instead call[Notification.Builder.setBubbleMetadata(BubbleMetadata)](/reference/android/app/Notification.Builder#setBubbleMetadata%28android.app.Notification.BubbleMetadata%29) 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 to be bitwise-ORed into the [flags](/reference/android/app/Notification#flags) field that should be set if this notification represents a currently running service. This will normally be set for you by [Service.startForeground](/reference/android/app/Service#startForeground%28int,%20android.app.Notification%29).
Constant Value: 64 (0x00000040)
FLAG_GROUP_SUMMARY
public static final int FLAG_GROUP_SUMMARY
Bit to be bitwise-ORed into the [flags](/reference/android/app/Notification#flags) field that should be set 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 [Builder.setGroup](/reference/android/app/Notification.Builder#setGroup%28java.lang.String%29).
Constant Value: 512 (0x00000200)
FLAG_HIGH_PRIORITY
public static final int FLAG_HIGH_PRIORITY
This constant was deprecated in API level 16.
Use [priority](/reference/android/app/Notification#priority) 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 to be bitwise-ORed into the [flags](/reference/android/app/Notification#flags) field that if set, 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 to be bitwise-ORed into the [flags](/reference/android/app/Notification#flags) field that should be set 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 to be bitwise-ORed into the [flags](/reference/android/app/Notification#flags) field that should be set 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 to be bitwise-ORed into the [flags](/reference/android/app/Notification#flags) field that should be set 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 to be bitwise-ORed into the [flags](/reference/android/app/Notification#flags) field that should be set if you would only like the sound, vibrate and ticker to be played if the notification was not already showing.
Note that using this flag will stop any ongoing alerting behaviour such as sound, vibration or blinking notification LED.
Constant Value: 8 (0x00000008)
FLAG_PROMOTED_ONGOING
public static final int FLAG_PROMOTED_ONGOING
Bit to be bitwise-ORed into the [flags](/reference/android/app/Notification#flags) field that should be set by the system if this notification is a promoted ongoing notification, both because it[hasPromotableCharacteristics()](/reference/android/app/Notification#hasPromotableCharacteristics%28%29) and the user has not disabled the feature for this app.
Applications cannot set this flag directly, but the posting app and[NotificationListenerService](/reference/android/service/notification/NotificationListenerService) can read it.
Constant Value: 262144 (0x00040000)
FLAG_SHOW_LIGHTS
public static final int FLAG_SHOW_LIGHTS
This constant was deprecated in API level 26.
use [NotificationChannel.shouldShowLights()](/reference/android/app/NotificationChannel#shouldShowLights%28%29).
Bit to be bitwise-ORed into the [flags](/reference/android/app/Notification#flags) field that should be set if you want the LED on for this notification.
- To turn the LED off, pass 0 in the alpha channel for colorARGB or 0 for both ledOnMS and ledOffMS.
- To turn the LED on, pass 1 for ledOnMS and 0 for ledOffMS.
- To flash the LED, pass the number of milliseconds that it should be on and off to ledOnMS and ledOffMS.
Since hardware varies, you are not guaranteed that any of the values you pass are honored exactly. Use the system defaults if possible because they will be set to values that work on any given hardware.
The alpha channel must be set for forward compatibility.
Constant Value: 1 (0x00000001)
GROUP_ALERT_ALL
public static final int GROUP_ALERT_ALL
Constant for [Builder.setGroupAlertBehavior(int)](/reference/android/app/Notification.Builder#setGroupAlertBehavior%28int%29), 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 [Builder.setGroupAlertBehavior(int)](/reference/android/app/Notification.Builder#setGroupAlertBehavior%28int%29), meaning that the summary notification in a group should be silenced (no sound or vibration) even if they are posted to a [NotificationChannel](/reference/android/app/NotificationChannel) that has sound and/or vibration. 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 [Builder.setGroupAlertBehavior(int)](/reference/android/app/Notification.Builder#setGroupAlertBehavior%28int%29), meaning that all children notification in a group should be silenced (no sound or vibration) even if they are posted to a [NotificationChannel](/reference/android/app/NotificationChannel) that has sound and/or vibration. 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)
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
This constant was deprecated in API level 26.
use [NotificationManager.IMPORTANCE_DEFAULT](/reference/android/app/NotificationManager#IMPORTANCE%5FDEFAULT) instead.
Default notification [priority](/reference/android/app/Notification#priority). 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
This constant was deprecated in API level 26.
use [NotificationManager.IMPORTANCE_HIGH](/reference/android/app/NotificationManager#IMPORTANCE%5FHIGH) instead.
Higher [priority](/reference/android/app/Notification#priority), 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](/reference/android/app/Notification#PRIORITY%5FDEFAULT) items.
Constant Value: 1 (0x00000001)
PRIORITY_LOW
public static final int PRIORITY_LOW
This constant was deprecated in API level 26.
use [NotificationManager.IMPORTANCE_LOW](/reference/android/app/NotificationManager#IMPORTANCE%5FLOW) instead.
Lower [priority](/reference/android/app/Notification#priority), 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](/reference/android/app/Notification#PRIORITY%5FDEFAULT) items.
Constant Value: -1 (0xffffffff)
PRIORITY_MAX
public static final int PRIORITY_MAX
This constant was deprecated in API level 26.
use [NotificationManager.IMPORTANCE_HIGH](/reference/android/app/NotificationManager#IMPORTANCE%5FHIGH) instead.
Highest [priority](/reference/android/app/Notification#priority), 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
This constant was deprecated in API level 26.
use [NotificationManager.IMPORTANCE_MIN](/reference/android/app/NotificationManager#IMPORTANCE%5FMIN) instead.
Lowest [priority](/reference/android/app/Notification#priority); these items might not be shown to the user except under special circumstances, such as detailed notification logs.
Constant Value: -2 (0xfffffffe)
SEMANTIC_STYLE_CAUTION
public static final int SEMANTIC_STYLE_CAUTION
This value is used to annotate an element as indicating caution, moderate urgency, tardiness, or another \u201cintermediate\u201d value on the semantic hierarchy.
Caution is generally represented to users by styling the element with a yellow or orange color.
Constant Value: 3 (0x00000003)
SEMANTIC_STYLE_DANGER
public static final int SEMANTIC_STYLE_DANGER
This value is used to annotate an element as indicating danger, extreme urgency or lateness, or another \u201cextreme\u201d value on the semantic hierarchy.
Danger is generally represented to users by styling the element with a red color.
Constant Value: 4 (0x00000004)
SEMANTIC_STYLE_INFO
public static final int SEMANTIC_STYLE_INFO
This value is used to annotate an element as indicating information that should stand out from other content, but which doesn\u2019t fall on a scale or hierarchy. This can be thought of as a more neutral value that may be used in cases where the element is intended to stand out against elements with the other semantic styles -- for example if a [ProgressStyle](/reference/android/app/Notification.ProgressStyle) bar uses semantic style to color segments, this style would be appropriate for segments where the semantic hierarchy is unhelpful to the user.
Info is generally represented to users by styling the element with a color (like blue) that is clearly distinct from the colors used for other styles.
Constant Value: 1 (0x00000001)
SEMANTIC_STYLE_SAFE
public static final int SEMANTIC_STYLE_SAFE
This value is used to annotate an element as indicating safety, non-urgency, timeliness, or another \u201cmild\u201d value on the semantic hierarchy.
Safety is generally represented to users by styling the element with a green color.
Constant Value: 2 (0x00000002)
SEMANTIC_STYLE_UNSPECIFIED
public static final int SEMANTIC_STYLE_UNSPECIFIED
This is the default value for semantic style, signaling no particular semantics. An[Annotation](/reference/android/text/Annotation) with this style has no effect.
Constant Value: 0 (0x00000000)
STREAM_DEFAULT
public static final int STREAM_DEFAULT
This constant was deprecated in API level 21.
Use [NotificationChannel.getAudioAttributes()](/reference/android/app/NotificationChannel#getAudioAttributes%28%29) instead.
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](/reference/android/media/AudioManager#STREAM%5FNOTIFICATION).
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. Conceal sensitive or private information while screen sharing.
Constant Value: 0 (0x00000000)
VISIBILITY_PUBLIC
public static final int VISIBILITY_PUBLIC
Notification visibility: Show this notification in its entirety on all lockscreens and while screen sharing.
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 or while screen sharing.
Constant Value: -1 (0xffffffff)
Fields
CREATOR
public static final Creator<Notification> CREATOR
Parcelable.Creator that instantiates Notification objects
audioStreamType
public int audioStreamType
This field was deprecated in API level 21.
Use [audioAttributes](/reference/android/app/Notification#audioAttributes) instead.
The audio stream type to use when playing the sound. Should be one of the STREAM_ constants from[AudioManager](/reference/android/media/AudioManager).
category
public String category
One of the predefined notification categories (see the CATEGORY_* constants) that best describes this Notification. May be used by the system for ranking and filtering.
color
public int color
Accent color (an ARGB integer like the constants in [Color](/reference/android/graphics/Color)) to be applied by the standard Style templates when presenting this notification.
The current template design constructs a colorful header image by overlaying the[icon](/reference/android/app/Notification#icon) image (stenciled in white) atop a field of this color. Alpha components are ignored.
deleteIntent
public PendingIntent deleteIntent
The intent to execute when the notification is explicitly dismissed by the user, either with the "Clear All" button or by swiping it away individually.
This probably shouldn't be launching an activity since several of those will be sent at the same time.
public Bundle extras
Additional semantic data to be carried around with this Notification.
The extras keys defined here are intended to capture the original inputs to [Builder](/reference/android/app/Notification.Builder) APIs, and are intended to be used by[NotificationListenerService](/reference/android/service/notification/NotificationListenerService) implementations to extract detailed information from notification objects.
fullScreenIntent
public PendingIntent fullScreenIntent
An intent to launch instead of posting the notification to the status bar.
The system UI may choose to display a heads-up notification, instead of launching this intent, while the user is using the device.
headsUpContentView
public RemoteViews headsUpContentView
A medium-format version of [contentView](/reference/android/app/Notification#contentView), providing the Notification an opportunity to add action buttons to contentView. At its discretion, the system UI may choose to show this as a heads-up notification, which will pop up so the user can see it without leaving their current activity.
As of N, this field may be null. The heads-up notification view is determined by the inputs to [Notification.Builder](/reference/android/app/Notification.Builder); a custom RemoteViews can optionally be supplied with [Notification.Builder.setCustomHeadsUpContentView(RemoteViews)](/reference/android/app/Notification.Builder#setCustomHeadsUpContentView%28android.widget.RemoteViews%29).
icon
public int icon
This field was deprecated in API level 23.
Use [Builder.setSmallIcon(Icon)](/reference/android/app/Notification.Builder#setSmallIcon%28android.graphics.drawable.Icon%29) instead.
The resource id of a drawable to use as the icon in the status bar.
iconLevel
public int iconLevel
If the icon in the status bar is to have more than one level, you can set this. Otherwise, leave it at its default value of 0.
largeIcon
public Bitmap largeIcon
This field was deprecated in API level 23.
Use [Builder.setLargeIcon(Icon)](/reference/android/app/Notification.Builder#setLargeIcon%28android.graphics.drawable.Icon%29) instead.
A large bitmap to be shown in the notification content area.
ledOffMS
public int ledOffMS
This field was deprecated in API level 26.
use [NotificationChannel.shouldShowLights()](/reference/android/app/NotificationChannel#shouldShowLights%28%29).
The number of milliseconds for the LED to be off while it's flashing. The hardware will do its best approximation.
ledOnMS
public int ledOnMS
This field was deprecated in API level 26.
use [NotificationChannel.shouldShowLights()](/reference/android/app/NotificationChannel#shouldShowLights%28%29).
The number of milliseconds for the LED to be on while it's flashing. The hardware will do its best approximation.
number
public int number
The number of events that this notification represents. For example, in a new mail notification, this could be the number of unread messages.
The system may or may not use this field to modify the appearance of the notification. Starting with [Build.VERSION_CODES.O](/reference/android/os/Build.VERSION%5FCODES#O), the number may be displayed as a badge icon in Launchers that support badging.
priority
public int priority
This field was deprecated in API level 26.
use [NotificationChannel.getImportance()](/reference/android/app/NotificationChannel#getImportance%28%29) instead.
Relative priority for this notification.
Priority is an indication of how much of the user's valuable attention should be consumed by this notification. Low-priority notifications may be hidden from the user in certain situations, while the user might be interrupted for a higher-priority notification. The system will make a determination about how to interpret this priority when presenting the notification.
A notification that is at least [PRIORITY_HIGH](/reference/android/app/Notification#PRIORITY%5FHIGH) is more likely to be presented as a heads-up notification.
.
Value is one of the following:
[PRIORITY_DEFAULT](/reference/android/app/Notification#PRIORITY%5FDEFAULT)[PRIORITY_LOW](/reference/android/app/Notification#PRIORITY%5FLOW)[PRIORITY_MIN](/reference/android/app/Notification#PRIORITY%5FMIN)[PRIORITY_HIGH](/reference/android/app/Notification#PRIORITY%5FHIGH)[PRIORITY_MAX](/reference/android/app/Notification#PRIORITY%5FMAX)
publicVersion
public Notification publicVersion
Replacement version of this notification whose content will be shown in an insecure context such as atop a secure keyguard. See [visibility](/reference/android/app/Notification#visibility) and [VISIBILITY_PUBLIC](/reference/android/app/Notification#VISIBILITY%5FPUBLIC).
sound
public Uri sound
This field was deprecated in API level 26.
use [NotificationChannel.getSound()](/reference/android/app/NotificationChannel#getSound%28%29).
The sound to play.
A notification that is noisy is more likely to be presented as a heads-up notification.
To play the default notification sound, see [defaults](/reference/android/app/Notification#defaults).
tickerText
public CharSequence tickerText
Text that summarizes this notification for accessibility services.
As of the L release, this text is no longer shown on screen, but it is still useful to accessibility services (where it serves as an audible announcement of the notification's appearance).
tickerView
public RemoteViews tickerView
Formerly, a view showing the [tickerText](/reference/android/app/Notification#tickerText).
No longer displayed in the status bar as of API 21.
visibility
public int visibility
Sphere of visibility of this notification, which affects how and when the SystemUI reveals the notification's presence and contents in untrusted situations (namely, on the secure lockscreen and during screen sharing).
The default level, [VISIBILITY_PRIVATE](/reference/android/app/Notification#VISIBILITY%5FPRIVATE), behaves exactly as notifications have always done on Android: The notification's [icon](/reference/android/app/Notification#icon) and [tickerText](/reference/android/app/Notification#tickerText) (if available) are shown in all situations, but the contents are only available if the device is unlocked for the appropriate user and there is no active screen sharing session.
A more permissive policy can be expressed by [VISIBILITY_PUBLIC](/reference/android/app/Notification#VISIBILITY%5FPUBLIC); such a notification can be read even in an "insecure" context (that is, above a secure lockscreen or while screen sharing with a remote viewer). To modify the public version of this notification\u2014for example, to redact some portions\u2014see[Builder.setPublicVersion(Notification)](/reference/android/app/Notification.Builder#setPublicVersion%28android.app.Notification%29).
Finally, a notification can be made [VISIBILITY_SECRET](/reference/android/app/Notification#VISIBILITY%5FSECRET), which will suppress its icon and ticker until the user has bypassed the lockscreen.
Value is one of the following:
[VISIBILITY_PUBLIC](/reference/android/app/Notification#VISIBILITY%5FPUBLIC)[VISIBILITY_PRIVATE](/reference/android/app/Notification#VISIBILITY%5FPRIVATE)[VISIBILITY_SECRET](/reference/android/app/Notification#VISIBILITY%5FSECRET)
when
public long when
A timestamp related to this notification, in milliseconds since the epoch.
Default value: [Now](/reference/java/lang/System#currentTimeMillis%28%29).
Choose a timestamp that will be most relevant to the user. For most finite events, this corresponds to the time the event happened (or will happen, in the case of events that have yet to occur but about which the user is being informed). Indefinite events should be timestamped according to when the activity began.
Some examples:
- Notification of a new chat message should be stamped when the message was received.
- Notification of an ongoing file download (with a progress bar, for example) should be stamped when the download started.
- Notification of a completed file download should be stamped when the download finished.
- Notification of an upcoming meeting should be stamped with the time the meeting will begin (that is, in the future).
- Notification of an ongoing stopwatch (increasing timer) should be stamped with the watch's start time.
- Notification of an ongoing countdown timer should be stamped with the timer's end time.
For apps targeting [Build.VERSION_CODES.N](/reference/android/os/Build.VERSION%5FCODES#N) and above, this time is not shown anymore by default and must be opted into by using[Notification.Builder.setShowWhen(boolean)](/reference/android/app/Notification.Builder#setShowWhen%28boolean%29)
Public constructors
Notification
public Notification ()
Constructs a Notification object with default values. You should use [Builder](/reference/android/app/Notification.Builder) instead.
Notification
public Notification (Parcel parcel)
Unflatten the notification from a parcel.
| Parameters | |
|---|---|
| parcel | Parcel |
Notification
public Notification (int icon, CharSequence tickerText, long when)
This constructor is deprecated.
Use [Builder](/reference/android/app/Notification.Builder) instead.
Constructs a Notification object with the information needed to have a status bar icon without the standard expanded view.
| Parameters | |
|---|---|
| icon | int: the resource id of the icon to put in the status bar |
| tickerText | CharSequence: the text that flows by in the status bar when the notification first activates |
| when | long: the time to show in the time field, in the System.currentTimeMillis timebase |
Public methods
clone
public Notification clone ()
Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:
x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.
By convention, the returned object should be obtained by callingsuper.clone. If a class and all of its superclasses (exceptObject) obey this convention, it will be the case thatx.clone().getClass() == x.getClass().
By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.
| Returns | |
|---|---|
| Notification | a clone of this instance. |
createSemanticStyleAnnotation
public static Annotation createSemanticStyleAnnotation (int semanticStyle)
Constructs an [Annotation](/reference/android/text/Annotation) that can be used to span text in a [Spanned](/reference/android/text/Spanned) [CharSequence](/reference/java/lang/CharSequence) in some Notification text fields, and which may then be converted into styling of that section of text in order to indicate the semantic style. Since Notifications may strip styling, even for semantic styles, it\u2019s important that stripping these styles should not distort the meaning of the text.
Semantic style will only be applied to text appearance in notifications that are eligible (e.g. [promoted](/reference/android/app/Notification#FLAG%5FPROMOTED%5FONGOING) notifications).
| Parameters | |
|---|---|
| semanticStyle | int: Value is one of the following: SEMANTIC_STYLE_UNSPECIFIED SEMANTIC_STYLE_INFO SEMANTIC_STYLE_SAFE SEMANTIC_STYLE_CAUTION SEMANTIC_STYLE_DANGER |
| Returns | |
|---|---|
| Annotation | This value cannot be null. |
describeContents
public int describeContents ()
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of [writeToParcel(Parcel,int)](/reference/android/os/Parcelable#writeToParcel%28android.os.Parcel,%20int%29), the return value of this method must include the[CONTENTS_FILE_DESCRIPTOR](/reference/android/os/Parcelable#CONTENTS%5FFILE%5FDESCRIPTOR) bit.
| Returns | |
|---|---|
| int | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR |
findRemoteInputActionPair
public Pair<RemoteInput, Notification.Action> findRemoteInputActionPair (boolean requiresFreeform)
Finds and returns a remote input and its corresponding action.
| Parameters | |
|---|---|
| requiresFreeform | boolean: requires the remoteinput to allow freeform or not |
| Returns | |
|---|---|
| Pair<RemoteInput, Notification.Action> | the result pair, null if no result is found |
getAllowSystemGeneratedContextualActions
public boolean getAllowSystemGeneratedContextualActions ()
Returns whether the platform is allowed (by the app developer) to generate contextual actions for this notification.
| Returns |
|---|
| boolean |
getBadgeIconType
public int getBadgeIconType ()
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](/reference/android/app/Notification#BADGE%5FICON%5FNONE),[BADGE_ICON_SMALL](/reference/android/app/Notification#BADGE%5FICON%5FSMALL), or [BADGE_ICON_LARGE](/reference/android/app/Notification#BADGE%5FICON%5FLARGE).
| Returns |
|---|
| int |
getBridgedNotificationMetadata
public Notification.BridgedNotificationMetadata getBridgedNotificationMetadata ()
Returns the metadata associated with a notification originating on another device. A copy of the original notification is sent to this device by a bridging app. This metadata is used for displaying the notification as a bridged notification to the user.
| Returns | |
|---|---|
| Notification.BridgedNotificationMetadata | the metadata associated with the notification. This value may be null. |
getChannelId
public String getChannelId ()
Returns the id of the channel this notification posts to.
| Returns |
|---|
| String |
getContextualActions
public List<Notification.Action> getContextualActions ()
Returns the actions that are contextual (that is, suggested because of the content of the notification) out of the actions in this notification.
| Returns | |
|---|---|
| List<Notification.Action> | This value cannot be null. |
getGroup
public String getGroup ()
Get the key used to group this notification into a cluster or stack with other notifications on devices which support such rendering.
| Returns |
|---|
| String |
getLargeIcon
public Icon getLargeIcon ()
The large icon shown in this notification's content view.
| Returns |
|---|
| Icon |
getShortCriticalText
public String getShortCriticalText ()
Returns the very short text summarizing the most critical information contained in the notification, or null if this field was not set.
| Returns |
|---|
| String |
getShortcutId
public String getShortcutId ()
Returns the [id](/reference/android/content/pm/ShortcutInfo#getId%28%29) that this notification supersedes, if any.
Used by some Launchers that display notification content to hide shortcuts that duplicate notifications.
| Returns |
|---|
| String |
getSmallIcon
public Icon getSmallIcon ()
The small icon representing this notification in the status bar.
| Returns | |
|---|---|
| Icon | the small icon representing this notification |
getSortKey
public String getSortKey ()
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[Builder.setGroup](/reference/android/app/Notification.Builder#setGroup%28java.lang.String%29).
| Returns |
|---|
| String |
getTimeoutAfter
public long getTimeoutAfter ()
Returns the duration from posting after which this notification should be canceled by the system, if it's not canceled already.
| Returns |
|---|
| long |
hasImage
public boolean hasImage ()
| Returns | |
|---|---|
| boolean | true if the notification has an image |
hasPromotableCharacteristics
public boolean hasPromotableCharacteristics ()
Returns whether the notification has all the characteristics that make it eligible for[FLAG_PROMOTED_ONGOING](/reference/android/app/Notification#FLAG%5FPROMOTED%5FONGOING). This method does not factor in other criteria such user preferences for the app or channel. If this returns true, it does not guarantee that the notification will be assigned [FLAG_PROMOTED_ONGOING](/reference/android/app/Notification#FLAG%5FPROMOTED%5FONGOING) by the system, but if this returns false, it will not.
| Returns |
|---|
| boolean |
hasSummarizedContent
public boolean hasSummarizedContent ()
Returns whether this notification contains computationally summarized text. The OS may choose to display this content instead of the original notification content on some surfaces and may add styling to indicate to the user that this was computationally generated.
| Returns |
|---|
| boolean |
toString
public String toString ()
Returns a string representation of the object.
| Returns | |
|---|---|
| String | a string representation of the object. |