Added in API level 1

Notification


open class Notification : Parcelable
kotlin.Any
   ↳ android.app.Notification

A class that represents how a persistent notification is to be presented to the user using the android.app.NotificationManager.

The Notification.Builder has been added to make it easier to construct Notifications.

Summary

Nested classes
open

Structure to encapsulate a named action that can be shown as part of this notification.

open

Helper class for generating large-format notifications that include a large image attachment.

open

Helper class for generating large-format notifications that include a lot of text.

Encapsulates the information needed to display a notification as a bubble.

open

Builder class for Notification objects.

open

Helper class for generating large-format notifications that include a large image attachment.

Helper class to add Android Auto extensions to notifications.

open

Notification style for custom views that are decorated by the system

open

Notification style for media custom views that are decorated by the system

abstract

Extender interface for use with Builder#extend.

open

Helper class for generating large-format notifications that include a list of (up to 5) strings.

open

Notification style for media playback notifications.

open

Helper class for generating large-format notifications that include multiple back-and-forth messages of varying types between any number of people.

abstract

An object that can apply a rich notification style to a Notification.Builder object.

Helper class to add Android TV extensions to notifications.

Helper class to add wearable extensions to notifications.

Constants
static Int

If this notification is being shown as a badge, use the getLargeIcon() to represent this notification.

static Int

If this notification is being shown as a badge, always show as a number.

static Int

If this notification is being shown as a badge, use the getSmallIcon() to represent this notification.

static String

Notification category: alarm or timer.

static String

Notification category: incoming call (voice or video) or similar synchronous communication request.

static String

Notification category: asynchronous bulk message (email).

static String

Notification category: error in background operation or authentication status.

static String

Notification category: calendar event.

static String

Notification category: temporarily sharing location.

static String

Notification category: incoming direct message (SMS, instant message, etc.).

static String

Notification category: missed call.

static String

Notification category: map turn-by-turn navigation.

static String

Notification category: progress of a long-running background operation.

static String

Notification category: promotion or advertisement.

static String

Notification category: a specific, timely recommendation for a single thing.

static String

Notification category: user-scheduled reminder.

static String

Notification category: indication of running background service.

static String

Notification category: social network or sharing update.

static String

Notification category: ongoing information about device or contextual status.

static String

Notification category: running stopwatch.

static String

Notification category: system or device status update.

static String

Notification category: media transport control for playback.

static String

Notification category: voicemail.

static String

Notification category: tracking a user's workout.

static Int

Special value of color telling the system not to decorate this notification with any special color but instead use default colors when presenting this notification.

static Int

Use all default values (where applicable).

static Int

Use the default notification lights.

static Int

Use the default notification sound.

static Int

Use the default notification vibrate.

static String

extras key: the color used as a hint for the Answer action button of a android.app.Notification.CallStyle notification.

static String

extras key: the intent to be sent when the users answers a android.app.Notification.CallStyle notification.

static String

extras key: the audio contents of this notification.

static String

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.

static String

extras key: this is the longer text shown in the big form of a BigTextStyle notification, as supplied to BigTextStyle#bigText(CharSequence).

static String

extras key: whether the android.app.Notification.CallStyle notification is for a call that will activate video when answered.

static String

extras key: the person to be displayed as calling for the android.app.Notification.CallStyle notification.

static String

extras key: the type of call represented by the android.app.Notification.CallStyle notification.

static String

Optional extra for INTENT_CATEGORY_NOTIFICATION_PREFERENCES.

static String

Optional extra for INTENT_CATEGORY_NOTIFICATION_PREFERENCES.

static String

extras key: whether the chronometer set on the notification should count down instead of counting up.

static String

extras key: whether the notification should be colorized as supplied to Builder#setColorized(boolean).

static String

extras key: the indices of actions to be shown in the compact view, as supplied to (e.g.)

static String

extras key: a CharSequence to be displayed as the title to a conversation represented by a android.app.Notification.MessagingStyle

static String

extras key: the color used as a hint for the Decline or Hang Up action button of a android.app.Notification.CallStyle notification.

static String

extras key: the intent to be sent when the users declines a android.app.Notification.CallStyle notification.

static String

extras key: the intent to be sent when the users hangs up a android.app.Notification.CallStyle notification.

static String

extras key: an array of historic android.app.Notification.MessagingStyle.Message bundles provided by a android.app.Notification.MessagingStyle notification.

static String

extras key: this is a small piece of additional text as supplied to Builder#setContentInfo(CharSequence).

static String

extras key: whether the android.app.Notification.MessagingStyle notification represents a group conversation.

static String

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).

static String

extras key: this is a bitmap to be used instead of the one from Builder#setLargeIcon(android.graphics.Bitmap) when the notification is shown in its expanded form, as supplied to BigPictureStyle#bigLargeIcon(android.graphics.Bitmap).

static String

extras key: A android.media.session.MediaSession.Token associated with a android.app.Notification.MediaStyle notification.

static String

extras key: an array of android.app.Notification.MessagingStyle.Message bundles provided by a android.app.Notification.MessagingStyle notification.

static String

extras key: the person to be displayed for all messages sent by the user including direct replies android.app.Notification.MessagingStyle notification.

static String

Optional extra for INTENT_CATEGORY_NOTIFICATION_PREFERENCES.

static String

Optional extra for INTENT_CATEGORY_NOTIFICATION_PREFERENCES.

static String

extras key: A String array containing the people that this notification relates to, each of which was supplied to Builder#addPerson(String).

static String

extras key: An arrayList of Person objects containing the people that this notification relates to.

static String

extras key: this is a bitmap to be shown in BigPictureStyle expanded notifications, supplied to BigPictureStyle#bigPicture(android.graphics.Bitmap).

static String

extras key: this is a content description of the big picture supplied from BigPictureStyle#bigPicture(Bitmap), supplied to BigPictureStyle#setContentDescription(CharSequence).

static String

extras key: this is an Icon of an image to be shown in BigPictureStyle expanded notifications, supplied to BigPictureStyle#bigPicture(Icon).

static String

extras key: this is the progress value supplied to Builder#setProgress(int, int, boolean).

static String

extras key: whether the progress bar is indeterminate, supplied to Builder#setProgress(int, int, boolean).

static String

extras key: this is the maximum value supplied to Builder#setProgress(int, int, boolean).

static String

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.

static String

extras key: this is the remote input history, as supplied to Builder#setRemoteInputHistory(CharSequence[]).

static String

extras key: the username to be displayed for all messages sent by the user including direct replies android.app.Notification.MessagingStyle notification.

static String

extras key: this is a boolean to indicate that the big picture is to be shown in the collapsed state of a BigPictureStyle notification.

static String

extras key: whether when should be shown as a count-up timer (specifically a android.widget.Chronometer) instead of a timestamp, as supplied to Builder#setUsesChronometer(boolean).

static String

extras key: whether when should be shown, as supplied to Builder#setShowWhen(boolean).

static String

extras key: this is the resource ID of the notification's main small icon, as supplied to Builder#setSmallIcon(int).

static String

extras key: this is a third line of text, as supplied to Builder#setSubText(CharSequence).

static String

extras key: this is a line of summary information intended to be shown alongside expanded notifications, as supplied to (e.g.)

static String

extras key: A string representing the name of the specific android.app.Notification.Style used to create this notification.

static String

extras key: this is the main text payload, as supplied to Builder#setContentText(CharSequence).

static String

extras key: An array of CharSequences to show in InboxStyle expanded notifications, each of which was supplied to InboxStyle#addLine(CharSequence).

static String

extras key: this is the title of the notification, as supplied to Builder#setContentTitle(CharSequence).

static String

extras key: this is the title of the notification when shown in expanded form, e.

static String

extras key: the icon to be displayed as a verification status of the caller on a android.app.Notification.CallStyle notification.

static String

extras key: the text to be displayed as a verification status of the caller on a android.app.Notification.CallStyle notification.

static Int

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.

static Int

Bit to be bitswised-ored into the flags field that should be set by the system if this notification is showing as a bubble.

static Int

Bit to be bitwise-ored into the flags field that should be set if this notification represents a currently running service.

static Int

Bit to be bitswise-ored into the flags field that should be set if this notification is the group summary for a group of notifications.

static Int

Obsolete flag indicating high-priority notifications; use the priority field instead.

static Int

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.

static Int

Bit to be bitswise-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.

static Int

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.

static Int

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.

static Int

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.

static Int

Bit to be bitwise-ored into the flags field that should be set if you want the LED on for this notification.

static Int

If the Notification associated with starting a foreground service has been built using setForegroundServiceBehavior() with this behavior, display of the notification will usually be suppressed for a short time to avoid visual disturbances to the user.

static Int

If the Notification associated with starting a foreground service has been built using setForegroundServiceBehavior() with this behavior, display of the notification will usually be suppressed for a short time to avoid visual disturbances to the user.

static Int

If the Notification associated with starting a foreground service has been built using setForegroundServiceBehavior() with this behavior, display of the notification will be immediate even if the default behavior would be to defer visibility for a short time.

static Int

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.

static Int

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.

static Int

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.

static String

An activity that provides a user interface for adjusting notification preferences for its containing application.

static Int

Default notification priority.

static Int

Higher priority, for more important notifications or alerts.

static Int

Lower priority, for items that are less important.

static Int

Highest priority, for your application's most important items that require the user's prompt attention or input.

static Int

Lowest priority; these items might not be shown to the user except under special circumstances, such as detailed notification logs.

static Int

Use this constant as the value for audioStreamType to request that the default stream type for notifications be used.

static Int

Notification visibility: Show this notification on all lockscreens, but conceal sensitive or private information on secure lockscreens.

static Int

Notification visibility: Show this notification in its entirety on all lockscreens and while screen sharing.

static Int

Notification visibility: Do not reveal any part of this notification on a secure lockscreen or while screen sharing.

Inherited constants
Public constructors

Constructs a Notification object with default values.

Notification(icon: Int, tickerText: CharSequence!, when: Long)

Constructs a Notification object with the information needed to have a status bar icon without the standard expanded view.

Notification(parcel: Parcel!)

Unflatten the notification from a parcel.

Public methods
open Notification!

open Int

open Pair<RemoteInput!, Notification.Action!>?

Finds and returns a remote input and its corresponding action.

open Boolean

Returns whether the platform is allowed (by the app developer) to generate contextual actions for this notification.

open Int

Returns what icon should be shown for this notification if it is being displayed in a Launcher that supports badging.

open Notification.BubbleMetadata?

Returns the bubble metadata that will be used to display app content in a floating window over the existing foreground activity.

open String!

Returns the id of the channel this notification posts to.

open MutableList<Notification.Action!>

Returns the actions that are contextual (that is, suggested because of the content of the notification) out of the actions in this notification.

open String!

Get the key used to group this notification into a cluster or stack with other notifications on devices which support such rendering.

open Int

Returns which type of notifications in a group are responsible for audibly alerting the user.

open Icon!

The large icon shown in this notification's content view.

open LocusId?

Gets the LocusId associated with this notification.

open CharSequence!

Returns the settings text provided to Builder#setSettingsText(CharSequence).

open String!

Returns the id that this notification supersedes, if any.

open Icon!

The small icon representing this notification in the status bar and content view.

open String!

Get a sort key that orders this notification among other notifications from the same package.

open Long

Returns the duration from posting after which this notification should be canceled by the system, if it's not canceled already.

open Boolean

open String

open Unit
writeToParcel(parcel: Parcel, flags: Int)

Flatten this notification into a parcel.

Properties
static AudioAttributes!

The default value of audioAttributes.

static Parcelable.Creator<Notification!>

Parcelable.

Array<Notification.Action!>!

Array of all Action structures attached to this notification by Builder#addAction(int, CharSequence, PendingIntent).

AudioAttributes!

The audio attributes to use when playing the sound.

Int

The audio stream type to use when playing the sound.

RemoteViews!

A large-format version of contentView, giving the Notification an opportunity to show more detail.

String!

One of the predefined notification categories (see the CATEGORY_* constants) that best describes this Notification.

Int

Accent color (an ARGB integer like the constants in android.graphics.Color) to be applied by the standard Style templates when presenting this notification.

PendingIntent!

The intent to execute when the expanded status entry is clicked.

RemoteViews!

The view that will represent this notification in the notification list (which is pulled down from the status bar).

Int

Specifies which values should be taken from the defaults.

PendingIntent!

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.

Bundle!

Additional semantic data to be carried around with this Notification.

Int

PendingIntent!

An intent to launch instead of posting the notification to the status bar.

RemoteViews!

A medium-format version of contentView, providing the Notification an opportunity to add action buttons to contentView.

Int

The resource id of a drawable to use as the icon in the status bar.

Int

If the icon in the status bar is to have more than one level, you can set this.

Bitmap!

A large bitmap to be shown in the notification content area.

Int

The color of the led.

Int

The number of milliseconds for the LED to be off while it's flashing.

Int

The number of milliseconds for the LED to be on while it's flashing.

Int

The number of events that this notification represents.

Int

Relative priority for this notification.

Notification!

Replacement version of this notification whose content will be shown in an insecure context such as atop a secure keyguard.

Uri!

The sound to play.

CharSequence!

Text that summarizes this notification for accessibility services.

RemoteViews!

Formerly, a view showing the tickerText.

LongArray!

The pattern with which to vibrate.

Int

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).

Long

A timestamp related to this notification, in milliseconds since the epoch.

Constants

BADGE_ICON_LARGE

Added in API level 26
static val BADGE_ICON_LARGE: Int

If this notification is being shown as a badge, use the getLargeIcon() to represent this notification.

Value: 2

BADGE_ICON_NONE

Added in API level 26
static val BADGE_ICON_NONE: Int

If this notification is being shown as a badge, always show as a number.

Value: 0

BADGE_ICON_SMALL

Added in API level 26
static val BADGE_ICON_SMALL: Int

If this notification is being shown as a badge, use the getSmallIcon() to represent this notification.

Value: 1

CATEGORY_ALARM

Added in API level 21
static val CATEGORY_ALARM: String

Notification category: alarm or timer.

Value: "alarm"

CATEGORY_CALL

Added in API level 21
static val CATEGORY_CALL: String

Notification category: incoming call (voice or video) or similar synchronous communication request.

Value: "call"

CATEGORY_EMAIL

Added in API level 21
static val CATEGORY_EMAIL: String

Notification category: asynchronous bulk message (email).

Value: "email"

CATEGORY_ERROR

Added in API level 21
static val CATEGORY_ERROR: String

Notification category: error in background operation or authentication status.

Value: "err"

CATEGORY_EVENT

Added in API level 21
static val CATEGORY_EVENT: String

Notification category: calendar event.

Value: "event"

CATEGORY_LOCATION_SHARING

Added in API level 31
static val CATEGORY_LOCATION_SHARING: String

Notification category: temporarily sharing location.

Value: "location_sharing"

CATEGORY_MESSAGE

Added in API level 21
static val CATEGORY_MESSAGE: String

Notification category: incoming direct message (SMS, instant message, etc.).

Value: "msg"

CATEGORY_MISSED_CALL

Added in API level 31
static val CATEGORY_MISSED_CALL: String

Notification category: missed call.

Value: "missed_call"

CATEGORY_NAVIGATION

Added in API level 28
static val CATEGORY_NAVIGATION: String

Notification category: map turn-by-turn navigation.

Value: "navigation"

CATEGORY_PROGRESS

Added in API level 21
static val CATEGORY_PROGRESS: String

Notification category: progress of a long-running background operation.

Value: "progress"

CATEGORY_PROMO

Added in API level 21
static val CATEGORY_PROMO: String

Notification category: promotion or advertisement.

Value: "promo"

CATEGORY_RECOMMENDATION

Added in API level 21
static val CATEGORY_RECOMMENDATION: String

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.

Value: "recommendation"

CATEGORY_REMINDER

Added in API level 23
static val CATEGORY_REMINDER: String

Notification category: user-scheduled reminder.

Value: "reminder"

CATEGORY_SERVICE

Added in API level 21
static val CATEGORY_SERVICE: String

Notification category: indication of running background service.

Value: "service"

CATEGORY_SOCIAL

Added in API level 21
static val CATEGORY_SOCIAL: String

Notification category: social network or sharing update.

Value: "social"

CATEGORY_STATUS

Added in API level 21
static val CATEGORY_STATUS: String

Notification category: ongoing information about device or contextual status.

Value: "status"

CATEGORY_STOPWATCH

Added in API level 31
static val CATEGORY_STOPWATCH: String

Notification category: running stopwatch.

Value: "stopwatch"

CATEGORY_SYSTEM

Added in API level 21
static val CATEGORY_SYSTEM: String

Notification category: system or device status update. Reserved for system use.

Value: "sys"

CATEGORY_TRANSPORT

Added in API level 21
static val CATEGORY_TRANSPORT: String

Notification category: media transport control for playback.

Value: "transport"

CATEGORY_VOICEMAIL

Added in API level 35
static val CATEGORY_VOICEMAIL: String

Notification category: voicemail.

Value: "voicemail"

CATEGORY_WORKOUT

Added in API level 31
static val CATEGORY_WORKOUT: String

Notification category: tracking a user's workout.

Value: "workout"

COLOR_DEFAULT

Added in API level 21
static val COLOR_DEFAULT: Int

Special value of color telling the system not to decorate this notification with any special color but instead use default colors when presenting this notification.

Value: 0

DEFAULT_ALL

Added in API level 1
static val DEFAULT_ALL: Int

Use all default values (where applicable).

Value: -1

DEFAULT_LIGHTS

Added in API level 1
static val DEFAULT_LIGHTS: Int

Use the default notification lights. This will ignore the FLAG_SHOW_LIGHTS bit, and ledARGB, ledOffMS, or ledOnMS.

Value: 4

See Also

DEFAULT_SOUND

Added in API level 1
static val DEFAULT_SOUND: Int

Use the default notification sound. This will ignore any given sound.

A notification that is noisy is more likely to be presented as a heads-up notification.

Value: 1

See Also

DEFAULT_VIBRATE

Added in API level 1
static val DEFAULT_VIBRATE: Int

Use the default notification vibrate. This will ignore any given vibrate. Using phone vibration requires the VIBRATE permission.

A notification that vibrates is more likely to be presented as a heads-up notification.

Value: 2

See Also

EXTRA_ANSWER_COLOR

Added in API level 31
static val EXTRA_ANSWER_COLOR: String

extras key: the color used as a hint for the Answer action button of a android.app.Notification.CallStyle notification. This extra is a ColorInt.

Value: "android.answerColor"

EXTRA_ANSWER_INTENT

Added in API level 31
static val EXTRA_ANSWER_INTENT: String

extras key: the intent to be sent when the users answers a android.app.Notification.CallStyle notification. This extra is a PendingIntent.

Value: "android.answerIntent"

EXTRA_AUDIO_CONTENTS_URI

Added in API level 26
static val EXTRA_AUDIO_CONTENTS_URI: String

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 since each Message has a field for holding data URI. That field can be used for audio. See Message#setData. Example usage:

<code>Notification.Builder myBuilder = (build your Notification as normal);
  myBuilder.getExtras().putString(EXTRA_AUDIO_CONTENTS_URI, myAudioUri.toString());
  </code>

Value: "android.audioContents"

EXTRA_BACKGROUND_IMAGE_URI

Added in API level 21
static val EXTRA_BACKGROUND_IMAGE_URI: String

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. Used on television platforms. The URI must point to an image stream suitable for passing into BitmapFactory.decodeStream; all other content types will be ignored.

Value: "android.backgroundImageUri"

EXTRA_BIG_TEXT

Added in API level 21
static val EXTRA_BIG_TEXT: String

extras key: this is the longer text shown in the big form of a BigTextStyle notification, as supplied to BigTextStyle#bigText(CharSequence).

Value: "android.bigText"

EXTRA_CALL_IS_VIDEO

Added in API level 31
static val EXTRA_CALL_IS_VIDEO: String

extras key: whether the android.app.Notification.CallStyle notification is for a call that will activate video when answered. This extra is a boolean.

Value: "android.callIsVideo"

EXTRA_CALL_PERSON

Added in API level 31
static val EXTRA_CALL_PERSON: String

extras key: the person to be displayed as calling for the android.app.Notification.CallStyle notification. This extra is a Person.

Value: "android.callPerson"

EXTRA_CALL_TYPE

Added in API level 34
static val EXTRA_CALL_TYPE: String

extras key: the type of call represented by the android.app.Notification.CallStyle notification. This extra is an int.

Value: "android.callType"

EXTRA_CHANNEL_GROUP_ID

Added in API level 28
static val EXTRA_CHANNEL_GROUP_ID: String

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.

Value: "android.intent.extra.CHANNEL_GROUP_ID"

EXTRA_CHANNEL_ID

Added in API level 26
static val EXTRA_CHANNEL_ID: String

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.

Value: "android.intent.extra.CHANNEL_ID"

EXTRA_CHRONOMETER_COUNT_DOWN

Added in API level 24
static val EXTRA_CHRONOMETER_COUNT_DOWN: String

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 false.

Value: "android.chronometerCountDown"

EXTRA_COLORIZED

Added in API level 26
static val EXTRA_COLORIZED: String

extras key: whether the notification should be colorized as supplied to Builder#setColorized(boolean).

Value: "android.colorized"

EXTRA_COMPACT_ACTIONS

Added in API level 21
static val EXTRA_COMPACT_ACTIONS: String

extras key: the indices of actions to be shown in the compact view, as supplied to (e.g.) MediaStyle#setShowActionsInCompactView(int...).

Value: "android.compactActions"

EXTRA_CONVERSATION_TITLE

Added in API level 24
static val EXTRA_CONVERSATION_TITLE: String

extras key: a CharSequence to be displayed as the title to a conversation represented by a android.app.Notification.MessagingStyle

Value: "android.conversationTitle"

EXTRA_DECLINE_COLOR

Added in API level 31
static val EXTRA_DECLINE_COLOR: String

extras key: the color used as a hint for the Decline or Hang Up action button of a android.app.Notification.CallStyle notification. This extra is a ColorInt.

Value: "android.declineColor"

EXTRA_DECLINE_INTENT

Added in API level 31
static val EXTRA_DECLINE_INTENT: String

extras key: the intent to be sent when the users declines a android.app.Notification.CallStyle notification. This extra is a PendingIntent.

Value: "android.declineIntent"

EXTRA_HANG_UP_INTENT

Added in API level 31
static val EXTRA_HANG_UP_INTENT: String

extras key: the intent to be sent when the users hangs up a android.app.Notification.CallStyle notification. This extra is a PendingIntent.

Value: "android.hangUpIntent"

EXTRA_HISTORIC_MESSAGES

Added in API level 26
static val EXTRA_HISTORIC_MESSAGES: String

extras key: an array of historic android.app.Notification.MessagingStyle.Message bundles provided by a android.app.Notification.MessagingStyle notification. This extra is a parcelable array of bundles.

Value: "android.messages.historic"

EXTRA_INFO_TEXT

Added in API level 19
static val EXTRA_INFO_TEXT: String

extras key: this is a small piece of additional text as supplied to Builder#setContentInfo(CharSequence).

Value: "android.infoText"

EXTRA_IS_GROUP_CONVERSATION

Added in API level 28
static val EXTRA_IS_GROUP_CONVERSATION: String

extras key: whether the android.app.Notification.MessagingStyle notification represents a group conversation.

Value: "android.isGroupConversation"

EXTRA_LARGE_ICON

Added in API level 19
Deprecated in API level 26
static val EXTRA_LARGE_ICON: String

Deprecated: Use getLargeIcon(), which supports a wider variety of icon sources.

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).

Value: "android.largeIcon"

EXTRA_LARGE_ICON_BIG

Added in API level 19
static val EXTRA_LARGE_ICON_BIG: String

extras key: this is a bitmap to be used instead of the one from Builder#setLargeIcon(android.graphics.Bitmap) when the notification is shown in its expanded form, as supplied to BigPictureStyle#bigLargeIcon(android.graphics.Bitmap).

Value: "android.largeIcon.big"

EXTRA_MEDIA_SESSION

Added in API level 21
static val EXTRA_MEDIA_SESSION: String

extras key: A android.media.session.MediaSession.Token associated with a android.app.Notification.MediaStyle notification.

Value: "android.mediaSession"

EXTRA_MESSAGES

Added in API level 24
static val EXTRA_MESSAGES: String

extras key: an array of android.app.Notification.MessagingStyle.Message bundles provided by a android.app.Notification.MessagingStyle notification. This extra is a parcelable array of bundles.

Value: "android.messages"

EXTRA_MESSAGING_PERSON

Added in API level 28
static val EXTRA_MESSAGING_PERSON: String

extras key: the person to be displayed for all messages sent by the user including direct replies android.app.Notification.MessagingStyle notification. This extra is a Person

Value: "android.messagingUser"

EXTRA_NOTIFICATION_ID

Added in API level 26
static val EXTRA_NOTIFICATION_ID: String

Optional extra for INTENT_CATEGORY_NOTIFICATION_PREFERENCES. If provided, will contain the id provided to NotificationManager#notify(String, int, Notification) that can be used to narrow down what settings should be shown in the target app.

Value: "android.intent.extra.NOTIFICATION_ID"

EXTRA_NOTIFICATION_TAG

Added in API level 26
static val EXTRA_NOTIFICATION_TAG: String

Optional extra for INTENT_CATEGORY_NOTIFICATION_PREFERENCES. If provided, will contain the tag provided to NotificationManager#notify(String, int, Notification) that can be used to narrow down what settings should be shown in the target app.

Value: "android.intent.extra.NOTIFICATION_TAG"

EXTRA_PEOPLE

Added in API level 19
Deprecated in API level 28
static val EXTRA_PEOPLE: String

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 Builder#addPerson(String).

Value: "android.people"

EXTRA_PEOPLE_LIST

Added in API level 28
static val EXTRA_PEOPLE_LIST: String

extras key: An arrayList of Person objects containing the people that this notification relates to.

Value: "android.people.list"

EXTRA_PICTURE

Added in API level 19
static val EXTRA_PICTURE: String

extras key: this is a bitmap to be shown in BigPictureStyle expanded notifications, supplied to BigPictureStyle#bigPicture(android.graphics.Bitmap).

Value: "android.picture"

EXTRA_PICTURE_CONTENT_DESCRIPTION

Added in API level 31
static val EXTRA_PICTURE_CONTENT_DESCRIPTION: String

extras key: this is a content description of the big picture supplied from BigPictureStyle#bigPicture(Bitmap), supplied to BigPictureStyle#setContentDescription(CharSequence).

Value: "android.pictureContentDescription"

EXTRA_PICTURE_ICON

Added in API level 31
static val EXTRA_PICTURE_ICON: String

extras key: this is an Icon of an image to be shown in BigPictureStyle expanded notifications, supplied to BigPictureStyle#bigPicture(Icon).

Value: "android.pictureIcon"

EXTRA_PROGRESS

Added in API level 19
static val EXTRA_PROGRESS: String

extras key: this is the progress value supplied to Builder#setProgress(int, int, boolean).

Value: "android.progress"

EXTRA_PROGRESS_INDETERMINATE

Added in API level 19
static val EXTRA_PROGRESS_INDETERMINATE: String

extras key: whether the progress bar is indeterminate, supplied to Builder#setProgress(int, int, boolean).

Value: "android.progressIndeterminate"

EXTRA_PROGRESS_MAX

Added in API level 19
static val EXTRA_PROGRESS_MAX: String

extras key: this is the maximum value supplied to Builder#setProgress(int, int, boolean).

Value: "android.progressMax"

EXTRA_REMOTE_INPUT_DRAFT

Added in API level 28
static val EXTRA_REMOTE_INPUT_DRAFT: String

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.

Apps may use this extra to prepopulate text fields in the app, where the user usually sends messages.

Value: "android.remoteInputDraft"

EXTRA_REMOTE_INPUT_HISTORY

Added in API level 24
static val EXTRA_REMOTE_INPUT_HISTORY: String

extras key: this is the remote input history, as supplied to Builder#setRemoteInputHistory(CharSequence[]). Apps can fill this through 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.

Value: "android.remoteInputHistory"

EXTRA_SELF_DISPLAY_NAME

Added in API level 24
Deprecated in API level 28
static val EXTRA_SELF_DISPLAY_NAME: String

Deprecated: use EXTRA_MESSAGING_PERSON

extras key: the username to be displayed for all messages sent by the user including direct replies android.app.Notification.MessagingStyle notification. This extra is a CharSequence

Value: "android.selfDisplayName"

EXTRA_SHOW_BIG_PICTURE_WHEN_COLLAPSED

Added in API level 31
static val EXTRA_SHOW_BIG_PICTURE_WHEN_COLLAPSED: String

extras key: this is a boolean to indicate that the big picture is to be shown in the collapsed state of a BigPictureStyle notification. This will replace a large icon in that state if one was provided.

Value: "android.showBigPictureWhenCollapsed"

EXTRA_SHOW_CHRONOMETER

Added in API level 19
static val EXTRA_SHOW_CHRONOMETER: String

extras key: whether when should be shown as a count-up timer (specifically a android.widget.Chronometer) instead of a timestamp, as supplied to Builder#setUsesChronometer(boolean).

Value: "android.showChronometer"

EXTRA_SHOW_WHEN

Added in API level 19
static val EXTRA_SHOW_WHEN: String

extras key: whether when should be shown, as supplied to Builder#setShowWhen(boolean).

Value: "android.showWhen"

EXTRA_SMALL_ICON

Added in API level 19
Deprecated in API level 26
static val EXTRA_SMALL_ICON: String

Deprecated: Use getSmallIcon(), which supports a wider variety of icon sources.

extras key: this is the resource ID of the notification's main small icon, as supplied to Builder#setSmallIcon(int).

Value: "android.icon"

EXTRA_SUB_TEXT

Added in API level 19
static val EXTRA_SUB_TEXT: String

extras key: this is a third line of text, as supplied to Builder#setSubText(CharSequence).

Value: "android.subText"

EXTRA_SUMMARY_TEXT

Added in API level 19
static val EXTRA_SUMMARY_TEXT: String

extras key: this is a line of summary information intended to be shown alongside expanded notifications, as supplied to (e.g.) BigTextStyle#setSummaryText(CharSequence).

Value: "android.summaryText"

EXTRA_TEMPLATE

Added in API level 21
static val EXTRA_TEMPLATE: String

extras key: A string representing the name of the specific android.app.Notification.Style used to create this notification.

Value: "android.template"

EXTRA_TEXT

Added in API level 19
static val EXTRA_TEXT: String

extras key: this is the main text payload, as supplied to Builder#setContentText(CharSequence).

Value: "android.text"

EXTRA_TEXT_LINES

Added in API level 19
static val EXTRA_TEXT_LINES: String

extras key: An array of CharSequences to show in InboxStyle expanded notifications, each of which was supplied to InboxStyle#addLine(CharSequence).

Value: "android.textLines"

EXTRA_TITLE

Added in API level 19
static val EXTRA_TITLE: String

extras key: this is the title of the notification, as supplied to Builder#setContentTitle(CharSequence).

Value: "android.title"

EXTRA_TITLE_BIG

Added in API level 19
static val EXTRA_TITLE_BIG: String

extras key: this is the title of the notification when shown in expanded form, e.g. as supplied to BigTextStyle#setBigContentTitle(CharSequence).

Value: "android.title.big"

EXTRA_VERIFICATION_ICON

Added in API level 31
static val EXTRA_VERIFICATION_ICON: String

extras key: the icon to be displayed as a verification status of the caller on a android.app.Notification.CallStyle notification. This extra is an Icon.

Value: "android.verificationIcon"

EXTRA_VERIFICATION_TEXT

Added in API level 31
static val EXTRA_VERIFICATION_TEXT: String

extras key: the text to be displayed as a verification status of the caller on a android.app.Notification.CallStyle notification. This extra is a CharSequence.

Value: "android.verificationText"

FLAG_AUTO_CANCEL

Added in API level 1
static val FLAG_AUTO_CANCEL: Int

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.

Value: 16

FLAG_BUBBLE

Added in API level 29
static val FLAG_BUBBLE: Int

Bit to be bitswised-ored into the 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) 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.

Value: 4096

FLAG_FOREGROUND_SERVICE

Added in API level 5
static val FLAG_FOREGROUND_SERVICE: Int

Bit to be bitwise-ored into the flags field that should be set if this notification represents a currently running service. This will normally be set for you by android.app.Service#startForeground.

Value: 64

FLAG_GROUP_SUMMARY

Added in API level 20
static val FLAG_GROUP_SUMMARY: Int

Bit to be bitswise-ored into the 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.

Value: 512

FLAG_HIGH_PRIORITY

Added in API level 11
Deprecated in API level 16
static val FLAG_HIGH_PRIORITY: Int

Deprecated: Use priority with a positive value.

Obsolete flag indicating high-priority notifications; use the priority field instead.

Value: 128

FLAG_INSISTENT

Added in API level 1
static val FLAG_INSISTENT: Int

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.

Value: 4

FLAG_LOCAL_ONLY

Added in API level 20
static val FLAG_LOCAL_ONLY: Int

Bit to be bitswise-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.

Value: 256

FLAG_NO_CLEAR

Added in API level 1
static val FLAG_NO_CLEAR: Int

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.

Value: 32

FLAG_ONGOING_EVENT

Added in API level 1
static val FLAG_ONGOING_EVENT: Int

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. 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.

Value: 2

FLAG_ONLY_ALERT_ONCE

Added in API level 1
static val FLAG_ONLY_ALERT_ONCE: Int

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. Note that using this flag will stop any ongoing alerting behaviour such as sound, vibration or blinking notification LED.

Value: 8

FLAG_SHOW_LIGHTS

Added in API level 1
Deprecated in API level 26
static val FLAG_SHOW_LIGHTS: Int

Deprecated: use NotificationChannel#shouldShowLights().

Bit to be bitwise-ored into the 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.

Value: 1

FOREGROUND_SERVICE_DEFAULT

Added in API level 31
static val FOREGROUND_SERVICE_DEFAULT: Int

If the Notification associated with starting a foreground service has been built using setForegroundServiceBehavior() with this behavior, display of the notification will usually be suppressed for a short time to avoid visual disturbances to the user.
Value is android.app.Notification#FOREGROUND_SERVICE_DEFAULT, android.app.Notification#FOREGROUND_SERVICE_IMMEDIATE, or android.app.Notification#FOREGROUND_SERVICE_DEFERRED

Value: 0

FOREGROUND_SERVICE_DEFERRED

Added in API level 31
static val FOREGROUND_SERVICE_DEFERRED: Int

If the Notification associated with starting a foreground service has been built using setForegroundServiceBehavior() with this behavior, display of the notification will usually be suppressed for a short time to avoid visual disturbances to the user.
Value is android.app.Notification#FOREGROUND_SERVICE_DEFAULT, android.app.Notification#FOREGROUND_SERVICE_IMMEDIATE, or android.app.Notification#FOREGROUND_SERVICE_DEFERRED

Value: 2

FOREGROUND_SERVICE_IMMEDIATE

Added in API level 31
static val FOREGROUND_SERVICE_IMMEDIATE: Int

If the Notification associated with starting a foreground service has been built using setForegroundServiceBehavior() with this behavior, display of the notification will be immediate even if the default behavior would be to defer visibility for a short time.
Value is android.app.Notification#FOREGROUND_SERVICE_DEFAULT, android.app.Notification#FOREGROUND_SERVICE_IMMEDIATE, or android.app.Notification#FOREGROUND_SERVICE_DEFERRED

Value: 1

GROUP_ALERT_ALL

Added in API level 26
static val GROUP_ALERT_ALL: Int

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.

Value: 0

GROUP_ALERT_CHILDREN

Added in API level 26
static val GROUP_ALERT_CHILDREN: Int

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. 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.

Value: 2

GROUP_ALERT_SUMMARY

Added in API level 26
static val GROUP_ALERT_SUMMARY: Int

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. 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.

Value: 1

INTENT_CATEGORY_NOTIFICATION_PREFERENCES

Added in API level 21
static val INTENT_CATEGORY_NOTIFICATION_PREFERENCES: String

An activity that provides a user interface for adjusting notification preferences for its containing application.

Value: "android.intent.category.NOTIFICATION_PREFERENCES"

PRIORITY_DEFAULT

Added in API level 16
Deprecated in API level 26
static val PRIORITY_DEFAULT: Int

Deprecated: use NotificationManager#IMPORTANCE_DEFAULT instead.

Default notification priority. If your application does not prioritize its own notifications, use this value for all notifications.

Value: 0

PRIORITY_HIGH

Added in API level 16
Deprecated in API level 26
static val PRIORITY_HIGH: Int

Deprecated: use NotificationManager#IMPORTANCE_HIGH instead.

Higher 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 items.

Value: 1

PRIORITY_LOW

Added in API level 16
Deprecated in API level 26
static val PRIORITY_LOW: Int

Deprecated: use NotificationManager#IMPORTANCE_LOW instead.

Lower 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 items.

Value: -1

PRIORITY_MAX

Added in API level 16
Deprecated in API level 26
static val PRIORITY_MAX: Int

Deprecated: use NotificationManager#IMPORTANCE_HIGH instead.

Highest priority, for your application's most important items that require the user's prompt attention or input.

Value: 2

PRIORITY_MIN

Added in API level 16
Deprecated in API level 26
static val PRIORITY_MIN: Int

Deprecated: use NotificationManager#IMPORTANCE_MIN instead.

Lowest priority; these items might not be shown to the user except under special circumstances, such as detailed notification logs.

Value: -2

STREAM_DEFAULT

Added in API level 1
Deprecated in API level 21
static val STREAM_DEFAULT: Int

Deprecated: Use NotificationChannel#getAudioAttributes() 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.

Value: -1

VISIBILITY_PRIVATE

Added in API level 21
static val VISIBILITY_PRIVATE: Int

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. {@see #visibility}

Value: 0

VISIBILITY_PUBLIC

Added in API level 21
static val VISIBILITY_PUBLIC: Int

Notification visibility: Show this notification in its entirety on all lockscreens and while screen sharing. {@see #visibility}

Value: 1

VISIBILITY_SECRET

Added in API level 21
static val VISIBILITY_SECRET: Int

Notification visibility: Do not reveal any part of this notification on a secure lockscreen or while screen sharing. {@see #visibility}

Value: -1

Public constructors

Notification

Added in API level 1
Notification()

Constructs a Notification object with default values. You might want to consider using Builder instead.

Notification

Added in API level 1
Notification(
    icon: Int,
    tickerText: CharSequence!,
    when: Long)

Deprecated: Use 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.

Notification

Added in API level 1
Notification(parcel: Parcel!)

Unflatten the notification from a parcel.

Public methods

clone

Added in API level 1
open fun clone(): Notification!
Return
Notification! a clone of this instance.
Exceptions
java.lang.CloneNotSupportedException if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.

describeContents

Added in API level 1
open fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

findRemoteInputActionPair

Added in API level 30
open fun findRemoteInputActionPair(requiresFreeform: Boolean): Pair<RemoteInput!, Notification.Action!>?

Finds and returns a remote input and its corresponding action.

Parameters
requiresFreeform Boolean: requires the remoteinput to allow freeform or not.
Return
Pair<RemoteInput!, Notification.Action!>? the result pair, null if no result is found.

getAllowSystemGeneratedContextualActions

Added in API level 29
open fun getAllowSystemGeneratedContextualActions(): Boolean

Returns whether the platform is allowed (by the app developer) to generate contextual actions for this notification.

getBadgeIconType

Added in API level 26
open fun getBadgeIconType(): Int

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.

getBubbleMetadata

Added in API level 29
open fun getBubbleMetadata(): Notification.BubbleMetadata?

Returns the bubble metadata that will be used to display app content in a floating window over the existing foreground activity.

Return
Notification.BubbleMetadata? This value may be null.

getChannelId

Added in API level 26
open fun getChannelId(): String!

Returns the id of the channel this notification posts to.

getContextualActions

Added in API level 30
open fun getContextualActions(): MutableList<Notification.Action!>

Returns the actions that are contextual (that is, suggested because of the content of the notification) out of the actions in this notification.

Return
MutableList<Notification.Action!> This value cannot be null.

getGroup

Added in API level 20
open fun getGroup(): String!

Get the key used to group this notification into a cluster or stack with other notifications on devices which support such rendering.

getGroupAlertBehavior

Added in API level 26
open fun getGroupAlertBehavior(): Int

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.

Return
Int Value is android.app.Notification#GROUP_ALERT_ALL, android.app.Notification#GROUP_ALERT_CHILDREN, or android.app.Notification#GROUP_ALERT_SUMMARY

getLargeIcon

Added in API level 23
open fun getLargeIcon(): Icon!

The large icon shown in this notification's content view.

getLocusId

Added in API level 29
open fun getLocusId(): LocusId?

Gets the LocusId associated with this notification.

Used by the device's intelligence services to correlate objects (such as ShortcutInfo and ContentCaptureContext) that are correlated.

Return
LocusId? This value may be null.

getSettingsText

Added in API level 26
open fun getSettingsText(): CharSequence!

Returns the settings text provided to Builder#setSettingsText(CharSequence).

getShortcutId

Added in API level 26
open fun getShortcutId(): String!

Returns the id that this notification supersedes, if any.

Used by some Launchers that display notification content to hide shortcuts that duplicate notifications.

getSmallIcon

Added in API level 23
open fun getSmallIcon(): Icon!

The small icon representing this notification in the status bar and content view.

Return
Icon! the small icon representing this notification.

getSortKey

Added in API level 20
open fun getSortKey(): String!

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.

getTimeoutAfter

Added in API level 26
open fun getTimeoutAfter(): Long

Returns the duration from posting after which this notification should be canceled by the system, if it's not canceled already.

hasImage

Added in API level 31
open fun hasImage(): Boolean
Return
Boolean true if the notification has image

toString

Added in API level 1
open fun toString(): String
Return
String a string representation of the object.

writeToParcel

Added in API level 1
open fun writeToParcel(
    parcel: Parcel,
    flags: Int
): Unit

Flatten this notification into a parcel.

Parameters
dest The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

AUDIO_ATTRIBUTES_DEFAULT

Added in API level 21
static val AUDIO_ATTRIBUTES_DEFAULT: AudioAttributes!

The default value of audioAttributes.

CREATOR

Added in API level 1
static val CREATOR: Parcelable.Creator<Notification!>

Parcelable.Creator that instantiates Notification objects

actions

Added in API level 19
var actions: Array<Notification.Action!>!

Array of all Action structures attached to this notification by Builder#addAction(int, CharSequence, PendingIntent). Mostly useful for instances of android.service.notification.NotificationListenerService that provide an alternative interface for invoking actions.

audioAttributes

Added in API level 21
Deprecated in API level 26
var audioAttributes: AudioAttributes!

Deprecated: use NotificationChannel#getAudioAttributes() instead.

The audio attributes to use when playing the sound.

audioStreamType

Added in API level 1
Deprecated in API level 21
var audioStreamType: Int

Deprecated: Use audioAttributes instead.

The audio stream type to use when playing the sound. Should be one of the STREAM_ constants from android.media.AudioManager.

bigContentView

Added in API level 16
Deprecated in API level 24
var bigContentView: RemoteViews!

Deprecated: Deprecated in Java.

A large-format version of contentView, giving the Notification an opportunity to show more detail. The system UI may choose to show this instead of the normal content view at its discretion. As of N, this field may be null. The expanded notification view is determined by the inputs to Notification.Builder; a custom RemoteViews can optionally be supplied with Notification.Builder#setCustomBigContentView(RemoteViews).

category

Added in API level 21
var category: String!

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

Added in API level 21
var color: Int

Accent color (an ARGB integer like the constants in 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 image (stenciled in white) atop a field of this color. Alpha components are ignored.

contentIntent

Added in API level 1
var contentIntent: PendingIntent!

The intent to execute when the expanded status entry is clicked. If this is an activity, it must include the android.content.Intent#FLAG_ACTIVITY_NEW_TASK flag, which requires that you take care of task management as described in the Tasks and Back Stack document. In particular, make sure to read the Start an Activity from a Notification page for the correct ways to launch an application from a notification.

contentView

Added in API level 1
Deprecated in API level 24
var contentView: RemoteViews!

Deprecated: Deprecated in Java.

The view that will represent this notification in the notification list (which is pulled down from the status bar). As of N, this field may be null. The notification view is determined by the inputs to Notification.Builder; a custom RemoteViews can optionally be supplied with Notification.Builder#setCustomContentView(RemoteViews).

defaults

Added in API level 1
Deprecated in API level 26
var defaults: Int

Deprecated: use NotificationChannel#getSound() and NotificationChannel#shouldShowLights() and NotificationChannel#shouldVibrate().

Specifies which values should be taken from the defaults.

To set, OR the desired from DEFAULT_SOUND, DEFAULT_VIBRATE, DEFAULT_LIGHTS. For all default values, use DEFAULT_ALL.

deleteIntent

Added in API level 1
var deleteIntent: PendingIntent!

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.

extras

Added in API level 19
var extras: Bundle!

Additional semantic data to be carried around with this Notification.

The extras keys defined here are intended to capture the original inputs to Builder APIs, and are intended to be used by android.service.notification.NotificationListenerService implementations to extract detailed information from notification objects.

flags

Added in API level 1
var flags: Int

fullScreenIntent

Added in API level 9
var fullScreenIntent: PendingIntent!

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

Added in API level 21
Deprecated in API level 24
var headsUpContentView: RemoteViews!

Deprecated: Deprecated in Java.

A medium-format version of 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; a custom RemoteViews can optionally be supplied with Notification.Builder#setCustomHeadsUpContentView(RemoteViews).

icon

Added in API level 1
Deprecated in API level 23
var icon: Int

Deprecated: Use Builder#setSmallIcon(Icon) instead.

The resource id of a drawable to use as the icon in the status bar.

iconLevel

Added in API level 1
var iconLevel: Int

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

Added in API level 11
Deprecated in API level 23
var largeIcon: Bitmap!

Deprecated: Use Builder#setLargeIcon(Icon) instead.

A large bitmap to be shown in the notification content area.

ledARGB

Added in API level 1
Deprecated in API level 26
var ledARGB: Int

Deprecated: use NotificationChannel#shouldShowLights().

The color of the led. The hardware will do its best approximation.

ledOffMS

Added in API level 1
Deprecated in API level 26
var ledOffMS: Int

Deprecated: use NotificationChannel#shouldShowLights().

The number of milliseconds for the LED to be off while it's flashing. The hardware will do its best approximation.

ledOnMS

Added in API level 1
Deprecated in API level 26
var ledOnMS: Int

Deprecated: use NotificationChannel#shouldShowLights().

The number of milliseconds for the LED to be on while it's flashing. The hardware will do its best approximation.

number

Added in API level 1
var number: Int

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 android.os.Build.VERSION_CODES#O, the number may be displayed as a badge icon in Launchers that support badging.

priority

Added in API level 16
Deprecated in API level 26
var priority: Int

Deprecated: use NotificationChannel#getImportance() 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 is more likely to be presented as a heads-up notification.


Value is android.app.Notification#PRIORITY_DEFAULT, android.app.Notification#PRIORITY_LOW, android.app.Notification#PRIORITY_MIN, android.app.Notification#PRIORITY_HIGH, or android.app.Notification#PRIORITY_MAX

publicVersion

Added in API level 21
var publicVersion: Notification!

Replacement version of this notification whose content will be shown in an insecure context such as atop a secure keyguard. See visibility and VISIBILITY_PUBLIC.

sound

Added in API level 1
Deprecated in API level 26
var sound: Uri!

Deprecated: use NotificationChannel#getSound().

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.

tickerText

Added in API level 1
var tickerText: CharSequence!

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).

See Also

tickerView

Added in API level 11
Deprecated in API level 21
var tickerView: RemoteViews!

Deprecated: Deprecated in Java.

Formerly, a view showing the tickerText. No longer displayed in the status bar as of API 21.

vibrate

Added in API level 1
Deprecated in API level 26
var vibrate: LongArray!

Deprecated: use NotificationChannel#getVibrationPattern().

The pattern with which to vibrate.

To vibrate the default pattern, see defaults.

visibility

Added in API level 21
var visibility: Int

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, behaves exactly as notifications have always done on Android: The notification's icon and 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; 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—for example, to redact some portions—see Builder#setPublicVersion(Notification). Finally, a notification can be made VISIBILITY_SECRET, which will suppress its icon and ticker until the user has bypassed the lockscreen.
Value is android.app.Notification#VISIBILITY_PUBLIC, android.app.Notification#VISIBILITY_PRIVATE, or android.app.Notification#VISIBILITY_SECRET

when

Added in API level 1
var when: Long

A timestamp related to this notification, in milliseconds since the epoch. Default value: Now. 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 android.os.Build.VERSION_CODES#N and above, this time is not shown anymore by default and must be opted into by using android.app.Notification.Builder#setShowWhen(boolean)