# Print output for @column tags ?>
public
class
Notification
extends Object
implements
Parcelable
java.lang.Object | |
↳ | android.app.Notification |
A class that represents how a persistent notification is to be presented to
the user using the NotificationManager
.
The Notification.Builder
has been added to make it
easier to construct Notifications.
For a guide to creating notifications, read the Status Bar Notifications developer guide.
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.BubbleMetadata
Encapsulates the information needed to display a notification as a bubble. |
class |
Notification.Builder
Builder class for |
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 system Instead 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 system Instead 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 |
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.Style
An object that can apply a rich notification style to a |
class |
Notification.WearableExtender
Helper class to add wearable extensions to notifications. |
Constants | |
---|---|
int |
BADGE_ICON_LARGE
If this notification is being shown as a badge, use the |
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 |
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_MESSAGE
Notification category: incoming direct message (SMS, instant message, etc.). |
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_SYSTEM
Notification category: system or device status update. |
String |
CATEGORY_TRANSPORT
Notification category: media transport control for playback. |
int |
COLOR_DEFAULT
Special value of |
int |
DEFAULT_ALL
Use all default values (where applicable). |
int |
DEFAULT_LIGHTS
Use the default notification lights. |
int |
DEFAULT_SOUND
Use the default notification sound. |
int |
DEFAULT_VIBRATE
Use the default notification vibrate. |
String |
EXTRA_AUDIO_CONTENTS_URI
|
String |
EXTRA_BACKGROUND_IMAGE_URI
|
String |
EXTRA_BIG_TEXT
|
String |
EXTRA_CHANNEL_GROUP_ID
Optional extra for |
String |
EXTRA_CHANNEL_ID
Optional extra for |
String |
EXTRA_CHRONOMETER_COUNT_DOWN
|
String |
EXTRA_COLORIZED
|
String |
EXTRA_COMPACT_ACTIONS
|
String |
EXTRA_CONVERSATION_TITLE
|
String |
EXTRA_HISTORIC_MESSAGES
|
String |
EXTRA_INFO_TEXT
|
String |
EXTRA_IS_GROUP_CONVERSATION
|
String |
EXTRA_LARGE_ICON
This constant is deprecated.
Use |
String |
EXTRA_LARGE_ICON_BIG
|
String |
EXTRA_MEDIA_SESSION
|
String |
EXTRA_MESSAGES
|
String |
EXTRA_MESSAGING_PERSON
|
String |
EXTRA_NOTIFICATION_ID
Optional extra for |
String |
EXTRA_NOTIFICATION_TAG
Optional extra for |
String |
EXTRA_PEOPLE
This constant is deprecated.
the actual objects are now in |
String |
EXTRA_PEOPLE_LIST
|
String |
EXTRA_PICTURE
|
String |
EXTRA_PROGRESS
|
String |
EXTRA_PROGRESS_INDETERMINATE
|
String |
EXTRA_PROGRESS_MAX
|
String |
EXTRA_REMOTE_INPUT_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 |
String |
EXTRA_REMOTE_INPUT_HISTORY
|
String |
EXTRA_SELF_DISPLAY_NAME
This constant is deprecated.
use |
String |
EXTRA_SHOW_CHRONOMETER
|
String |
EXTRA_SHOW_WHEN
|
String |
EXTRA_SMALL_ICON
This constant is deprecated.
Use |
String |
EXTRA_SUB_TEXT
|
String |
EXTRA_SUMMARY_TEXT
|
String |
EXTRA_TEMPLATE
|
String |
EXTRA_TEXT
|
String |
EXTRA_TEXT_LINES
|
String |
EXTRA_TITLE
|
String |
EXTRA_TITLE_BIG
|
int |
FLAG_AUTO_CANCEL
Bit to be bitwise-ored into the |
int |
FLAG_BUBBLE
Bit to be bitswised-ored into the |
int |
FLAG_FOREGROUND_SERVICE
Bit to be bitwise-ored into the |
int |
FLAG_GROUP_SUMMARY
Bit to be bitswise-ored into the |
int |
FLAG_HIGH_PRIORITY
This constant is deprecated.
Use |
int |
FLAG_INSISTENT
Bit to be bitwise-ored into the |
int |
FLAG_LOCAL_ONLY
Bit to be bitswise-ored into the |
int |
FLAG_NO_CLEAR
Bit to be bitwise-ored into the |
int |
FLAG_ONGOING_EVENT
Bit to be bitwise-ored into the |
int |
FLAG_ONLY_ALERT_ONCE
Bit to be bitwise-ored into the |
int |
FLAG_SHOW_LIGHTS
This constant is deprecated.
use |
int |
GROUP_ALERT_ALL
Constant for |
int |
GROUP_ALERT_CHILDREN
Constant for |
int |
GROUP_ALERT_SUMMARY
Constant for |
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 is deprecated.
use |
int |
PRIORITY_HIGH
This constant is deprecated.
use |
int |
PRIORITY_LOW
This constant is deprecated.
use |
int |
PRIORITY_MAX
This constant is deprecated.
use |
int |
PRIORITY_MIN
This constant is deprecated.
use |
int |
STREAM_DEFAULT
This constant is deprecated.
Use |
int |
VISIBILITY_PRIVATE
Notification visibility: Show this notification on all lockscreens, but conceal sensitive or private information on secure lockscreens. |
int |
VISIBILITY_PUBLIC
Notification visibility: Show this notification in its entirety on all lockscreens. |
int |
VISIBILITY_SECRET
Notification visibility: Do not reveal any part of this notification on a secure lockscreen. |
Inherited constants |
---|
Fields | |
---|---|
public
static
final
AudioAttributes |
AUDIO_ATTRIBUTES_DEFAULT
The default value of |
public
static
final
Creator<Notification> |
CREATOR
Parcelable.Creator that instantiates Notification objects |
public
Action[] |
actions
Array of all |
public
AudioAttributes |
audioAttributes
This field is deprecated.
use |
public
int |
audioStreamType
This field is deprecated.
Use |
public
RemoteViews |
bigContentView
A large-format version of |
public
String |
category
One of the predefined notification categories (see the |
public
int |
color
Accent color (an ARGB integer like the constants in |
public
PendingIntent |
contentIntent
The intent to execute when the expanded status entry is clicked. |
public
RemoteViews |
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 is deprecated.
use |
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. |
public
Bundle |
extras
Additional semantic data to be carried around with this Notification. |
public
int |
flags
|
public
PendingIntent |
fullScreenIntent
An intent to launch instead of posting the notification to the status bar. |
public
RemoteViews |
headsUpContentView
A medium-format version of |
public
int |
icon
This field is deprecated.
Use |
public
int |
iconLevel
If the icon in the status bar is to have more than one level, you can set this. |
public
Bitmap |
largeIcon
This field is deprecated.
Use |
public
int |
ledARGB
This field is deprecated.
use |
public
int |
ledOffMS
This field is deprecated.
use |
public
int |
ledOnMS
This field is deprecated.
use |
public
int |
number
The number of events that this notification represents. |
public
int |
priority
This field is deprecated.
use |
public
Notification |
publicVersion
Replacement version of this notification whose content will be shown in an insecure context such as atop a secure keyguard. |
public
Uri |
sound
This field is deprecated.
use |
public
CharSequence |
tickerText
Text that summarizes this notification for accessibility services. |
public
RemoteViews |
tickerView
Formerly, a view showing the |
public
long[] |
vibrate
This field is deprecated.
use |
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). |
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(int icon, CharSequence tickerText, long when)
This constructor is deprecated.
Use |
|
Notification(Parcel parcel)
Unflatten the notification from a parcel. |
Public methods | |
---|---|
Notification
|
clone()
Creates and returns a copy of this object. |
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.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 |
CharSequence
|
getSettingsText()
Returns the settings text provided to |
String
|
getShortcutId()
Returns the |
Icon
|
getSmallIcon()
The small icon representing this notification in the status bar and content view. |
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. |
String
|
toString()
Returns a string representation of the object. |
void
|
writeToParcel(Parcel parcel, int flags)
Flatten this notification into a parcel. |
Inherited methods | |
---|---|
public static final int BADGE_ICON_LARGE
If this notification is being shown as a badge, use the getLargeIcon()
to
represent this notification.
Constant Value: 2 (0x00000002)
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)
public static final int BADGE_ICON_SMALL
If this notification is being shown as a badge, use the getSmallIcon()
to
represent this notification.
Constant Value: 1 (0x00000001)
public static final String CATEGORY_ALARM
Notification category: alarm or timer.
Constant Value: "alarm"
public static final String CATEGORY_CALL
Notification category: incoming call (voice or video) or similar synchronous communication request.
Constant Value: "call"
public static final String CATEGORY_EMAIL
Notification category: asynchronous bulk message (email).
Constant Value: "email"
public static final String CATEGORY_ERROR
Notification category: error in background operation or authentication status.
Constant Value: "err"
public static final String CATEGORY_EVENT
Notification category: calendar event.
Constant Value: "event"
public static final String CATEGORY_MESSAGE
Notification category: incoming direct message (SMS, instant message, etc.).
Constant Value: "msg"
public static final String CATEGORY_NAVIGATION
Notification category: map turn-by-turn navigation.
Constant Value: "navigation"
public static final String CATEGORY_PROGRESS
Notification category: progress of a long-running background operation.
Constant Value: "progress"
public static final String CATEGORY_PROMO
Notification category: promotion or advertisement.
Constant Value: "promo"
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"
public static final String CATEGORY_REMINDER
Notification category: user-scheduled reminder.
Constant Value: "reminder"
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"
public static final String CATEGORY_STATUS
Notification category: ongoing information about device or contextual status.
Constant Value: "status"
public static final String CATEGORY_SYSTEM
Notification category: system or device status update. Reserved for system use.
Constant Value: "sys"
public static final String CATEGORY_TRANSPORT
Notification category: media transport control for playback.
Constant Value: "transport"
public static final int COLOR_DEFAULT
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.
Constant Value: 0 (0x00000000)
public static final int DEFAULT_ALL
Use all default values (where applicable).
Constant Value: -1 (0xffffffff)
public static final int DEFAULT_LIGHTS
Use the default notification lights. This will ignore the
FLAG_SHOW_LIGHTS
bit, and ledARGB
, ledOffMS
, or
ledOnMS
.
See also:
Constant Value: 4 (0x00000004)
public static final int DEFAULT_SOUND
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.
See also:
Constant Value: 1 (0x00000001)
public static final int DEFAULT_VIBRATE
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.
See also:
Constant Value: 2 (0x00000002)
public static final String EXTRA_AUDIO_CONTENTS_URI
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:
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
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.
Constant Value: "android.backgroundImageUri"
public static final String EXTRA_BIG_TEXT
extras
key: this is the longer text shown in the big form of a
BigTextStyle
notification, as supplied to
BigTextStyle#bigText(CharSequence)
.
Constant Value: "android.bigText"
public static final String EXTRA_CHANNEL_GROUP_ID
Optional extra for INTENT_CATEGORY_NOTIFICATION_PREFERENCES
. If provided, will
contain a NotificationChannelGroup#getId()
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_CHANNEL_ID
Optional extra for INTENT_CATEGORY_NOTIFICATION_PREFERENCES
. If provided, will
contain a NotificationChannel#getId()
that can be used to narrow down
what settings should be shown in the target app.
Constant Value: "android.intent.extra.CHANNEL_ID"
public static final String EXTRA_CHRONOMETER_COUNT_DOWN
extras
key: whether the chronometer set on the notification should count down
instead of counting up. Is only relevant if key EXTRA_SHOW_CHRONOMETER
is present.
This extra is a boolean. The default is false.
Constant Value: "android.chronometerCountDown"
public static final String EXTRA_COLORIZED
extras
key: whether the notification should be colorized as
supplied to Builder#setColorized(boolean)
.
Constant Value: "android.colorized"
public static final String EXTRA_COMPACT_ACTIONS
extras
key: the indices of actions to be shown in the compact view,
as supplied to (e.g.) MediaStyle#setShowActionsInCompactView(int...)
.
Constant Value: "android.compactActions"
public static final String EXTRA_CONVERSATION_TITLE
extras
key: a CharSequence
to be displayed as the title to a conversation
represented by a Notification.MessagingStyle
Constant Value: "android.conversationTitle"
public static final String EXTRA_HISTORIC_MESSAGES
extras
key: an array of
historic
Notification.MessagingStyle.Message
bundles provided by a
Notification.MessagingStyle
notification. This extra is a parcelable
array of bundles.
Constant Value: "android.messages.historic"
public static final String EXTRA_INFO_TEXT
extras
key: this is a small piece of additional text as supplied to
Builder#setContentInfo(CharSequence)
.
Constant Value: "android.infoText"
public static final String EXTRA_IS_GROUP_CONVERSATION
extras
key: whether the Notification.MessagingStyle
notification
represents a group conversation.
Constant Value: "android.isGroupConversation"
public static final String EXTRA_LARGE_ICON
This constant is 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)
.
Constant Value: "android.largeIcon"
public static final String EXTRA_LARGE_ICON_BIG
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)
.
Constant Value: "android.largeIcon.big"
public static final String EXTRA_MEDIA_SESSION
extras
key: A
MediaSession.Token
associated with a
Notification.MediaStyle
notification.
Constant Value: "android.mediaSession"
public static final String EXTRA_MESSAGES
extras
key: an array of Notification.MessagingStyle.Message
bundles provided by a
Notification.MessagingStyle
notification. This extra is a parcelable
array of bundles.
Constant Value: "android.messages"
public static final String EXTRA_MESSAGING_PERSON
extras
key: the person to be displayed for all messages sent by the user including
direct replies
Notification.MessagingStyle
notification. This extra is a
Person
Constant Value: "android.messagingUser"
public static final String EXTRA_NOTIFICATION_ID
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.
Constant Value: "android.intent.extra.NOTIFICATION_ID"
public static final String EXTRA_NOTIFICATION_TAG
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.
Constant Value: "android.intent.extra.NOTIFICATION_TAG"
public static final String EXTRA_PEOPLE
This constant is deprecated.
the actual objects are now in EXTRA_PEOPLE_LIST
extras
key: A String array containing the people that this notification relates to,
each of which was supplied to Builder#addPerson(String)
.
Constant Value: "android.people"
public static final String EXTRA_PEOPLE_LIST
extras
key: An arrayList of Person
objects containing the people that
this notification relates to.
Constant Value: "android.people.list"
public static final String EXTRA_PICTURE
extras
key: this is a bitmap to be shown in BigPictureStyle
expanded
notifications, supplied to BigPictureStyle#bigPicture(android.graphics.Bitmap)
.
Constant Value: "android.picture"
public static final String EXTRA_PROGRESS
extras
key: this is the progress value supplied to
Builder#setProgress(int, int, boolean)
.
Constant Value: "android.progress"
public static final String EXTRA_PROGRESS_INDETERMINATE
extras
key: whether the progress bar is indeterminate, supplied to
Builder#setProgress(int, int, boolean)
.
Constant Value: "android.progressIndeterminate"
public static final String EXTRA_PROGRESS_MAX
extras
key: this is the maximum value supplied to
Builder#setProgress(int, int, boolean)
.
Constant Value: "android.progressMax"
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
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
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.
Constant Value: "android.remoteInputHistory"
public static final String EXTRA_SELF_DISPLAY_NAME
This constant is deprecated.
use EXTRA_MESSAGING_PERSON
extras
key: the username to be displayed for all messages sent by the user including
direct replies
Notification.MessagingStyle
notification. This extra is a
CharSequence
Constant Value: "android.selfDisplayName"
public static final 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 to
Builder#setUsesChronometer(boolean)
.
Constant Value: "android.showChronometer"
public static final String EXTRA_SHOW_WHEN
extras
key: whether when
should be shown,
as supplied to Builder#setShowWhen(boolean)
.
Constant Value: "android.showWhen"
public static final String EXTRA_SMALL_ICON
This constant is 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)
.
Constant Value: "android.icon"
public static final String EXTRA_SUB_TEXT
extras
key: this is a third line of text, as supplied to
Builder#setSubText(CharSequence)
.
Constant Value: "android.subText"
public static final String EXTRA_SUMMARY_TEXT
extras
key: this is a line of summary information intended to be shown
alongside expanded notifications, as supplied to (e.g.)
BigTextStyle#setSummaryText(CharSequence)
.
Constant Value: "android.summaryText"
public static final String EXTRA_TEMPLATE
extras
key: A string representing the name of the specific
Notification.Style
used to create this notification.
Constant Value: "android.template"
public static final String EXTRA_TEXT
extras
key: this is the main text payload, as supplied to
Builder#setContentText(CharSequence)
.
Constant Value: "android.text"
public static final 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)
.
Constant Value: "android.textLines"
public static final String EXTRA_TITLE
extras
key: this is the title of the notification,
as supplied to Builder#setContentTitle(CharSequence)
.
Constant Value: "android.title"
public static final String EXTRA_TITLE_BIG
extras
key: this is the title of the notification when shown in expanded form,
e.g. as supplied to BigTextStyle#setBigContentTitle(CharSequence)
.
Constant Value: "android.title.big"
public static final 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.
Constant Value: 16 (0x00000010)
public static final int FLAG_BUBBLE
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.
Constant Value: 4096 (0x00001000)
public static final 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. This
will normally be set for you by Service#startForeground
.
Constant Value: 64 (0x00000040)
public static final int FLAG_GROUP_SUMMARY
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
.
Constant Value: 512 (0x00000200)
public static final int FLAG_HIGH_PRIORITY
This constant is deprecated.
Use priority
with a positive value.
Obsolete flag indicating high-priority notifications; use the priority field instead.
Constant Value: 128 (0x00000080)
public static final 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.
Constant Value: 4 (0x00000004)
public static final int FLAG_LOCAL_ONLY
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.
Constant Value: 256 (0x00000100)
public static final 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.
Constant Value: 32 (0x00000020)
public static final 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. 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)
public static final 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.
Constant Value: 8 (0x00000008)
public static final int FLAG_SHOW_LIGHTS
This constant is 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.
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)
public static final 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.
Constant Value: 0 (0x00000000)
public static final 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. 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)
public static final 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. 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)
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"
public static final int PRIORITY_DEFAULT
This constant is deprecated.
use NotificationManager#IMPORTANCE_DEFAULT
instead.
Default notification priority
. If your application does not prioritize its own
notifications, use this value for all notifications.
Constant Value: 0 (0x00000000)
public static final int PRIORITY_HIGH
This constant is 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.
Constant Value: 1 (0x00000001)
public static final int PRIORITY_LOW
This constant is 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.
Constant Value: -1 (0xffffffff)
public static final int PRIORITY_MAX
This constant is deprecated.
use NotificationManager#IMPORTANCE_HIGH
instead.
Highest priority
, for your application's most important items that require the
user's prompt attention or input.
Constant Value: 2 (0x00000002)
public static final int PRIORITY_MIN
This constant is 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.
Constant Value: -2 (0xfffffffe)
public static final int STREAM_DEFAULT
This constant is 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
.
Constant Value: -1 (0xffffffff)
public static final int VISIBILITY_PRIVATE
Notification visibility: Show this notification on all lockscreens, but conceal sensitive or private information on secure lockscreens.
See also:
Constant Value: 0 (0x00000000)
public static final int VISIBILITY_PUBLIC
Notification visibility: Show this notification in its entirety on all lockscreens.
See also:
Constant Value: 1 (0x00000001)
public static final int VISIBILITY_SECRET
Notification visibility: Do not reveal any part of this notification on a secure lockscreen.
See also:
Constant Value: -1 (0xffffffff)
public static final AudioAttributes AUDIO_ATTRIBUTES_DEFAULT
The default value of audioAttributes
.
public static final Creator<Notification> CREATOR
Parcelable.Creator that instantiates Notification objects
public Action[] actions
Array of all Action
structures attached to this notification by
Builder#addAction(int, CharSequence, PendingIntent)
. Mostly useful for instances of
NotificationListenerService
that provide an alternative
interface for invoking actions.
public AudioAttributes audioAttributes
This field is deprecated.
use NotificationChannel#getAudioAttributes()
instead.
The AudioAttributes
to use when playing the sound.
public int audioStreamType
This field is deprecated.
Use audioAttributes
instead.
The audio stream type to use when playing the sound.
Should be one of the STREAM_ constants from
AudioManager
.
public RemoteViews bigContentView
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)
.
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.
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.
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.
public PendingIntent contentIntent
The intent to execute when the expanded status entry is clicked. If
this is an activity, it must include the
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 notification section
Handling
Notifications for the correct ways to launch an application from a
notification.
public RemoteViews contentView
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)
.
public int defaults
This field is 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
.
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
APIs, and are intended to be used by
NotificationListenerService
implementations to extract
detailed information from notification objects.
public int flags
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.
public RemoteViews headsUpContentView
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)
.
public int icon
This field is deprecated.
Use Builder#setSmallIcon(Icon)
instead.
The resource id of a drawable to use as the icon in the status bar.
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.
public Bitmap largeIcon
This field is deprecated.
Use Builder#setLargeIcon(Icon)
instead.
A large bitmap to be shown in the notification content area.
public int ledARGB
This field is deprecated.
use NotificationChannel#shouldShowLights()
.
The color of the led. The hardware will do its best approximation.
See also:
public int ledOffMS
This field is 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.
See also:
public int ledOnMS
This field is 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.
See also:
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
, the number may be displayed as a
badge icon in Launchers that support badging.
public int priority
This field is 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.
PRIORITY_DEFAULT
, PRIORITY_LOW
, PRIORITY_MIN
, PRIORITY_HIGH
, or PRIORITY_MAX
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
and VISIBILITY_PUBLIC
.
public Uri sound
This field is 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
.
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).
See also:
public RemoteViews tickerView
Formerly, a view showing the tickerText
.
No longer displayed in the status bar as of API 21.
public long[] vibrate
This field is deprecated.
use NotificationChannel#getVibrationPattern()
.
The pattern with which to vibrate.
To vibrate the default pattern, see defaults
.
See also:
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).
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.
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).
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 VISIBILITY_PUBLIC
, VISIBILITY_PRIVATE
, or VISIBILITY_SECRET
public long when
A timestamp related to this notification, in milliseconds since the epoch.
Default value: System#currentTimeMillis()
.
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:
Build.VERSION_CODES.N
and above, this time is not shown
anymore by default and must be opted into by using
Notification.Builder.setShowWhen(boolean)
public Notification ()
Constructs a Notification object with default values.
You might want to consider using Builder
instead.
public Notification (int icon, CharSequence tickerText, long when)
This constructor is 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. |
public Notification (Parcel parcel)
Unflatten the notification from a parcel.
Parameters | |
---|---|
parcel |
Parcel |
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:
will be true, and that the expression:x.clone() != x
will bex.clone().getClass() == x.getClass()
true
, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x)
true
, this is not an absolute requirement.
By convention, the returned object should be obtained by calling
super.clone
. If a class and all of its superclasses (except
Object
) obey this convention, it will be the case that
x.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.
The method clone
for class Object
performs a
specific cloning operation. First, if the class of this object does
not implement the interface Cloneable
, then a
CloneNotSupportedException
is thrown. Note that all arrays
are considered to implement the interface Cloneable
and that
the return type of the clone
method of an array type T[]
is T[]
where T is any reference or primitive type.
Otherwise, this method creates a new instance of the class of this
object and initializes all its fields with exactly the contents of
the corresponding fields of this object, as if by assignment; the
contents of the fields are not themselves cloned. Thus, this method
performs a "shallow copy" of this object, not a "deep copy" operation.
The class Object
does not itself implement the interface
Cloneable
, so calling the clone
method on an object
whose class is Object
will result in throwing an
exception at run time.
Returns | |
---|---|
Notification |
a clone of this instance. |
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(android.os.Parcel, int)
,
the return value of this method must include the
CONTENTS_FILE_DESCRIPTOR
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 |
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. |
public boolean getAllowSystemGeneratedContextualActions ()
Returns whether the platform is allowed (by the app developer) to generate contextual actions for this notification.
Returns | |
---|---|
boolean |
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
,
BADGE_ICON_SMALL
, or BADGE_ICON_LARGE
.
Returns | |
---|---|
int |
public Notification.BubbleMetadata getBubbleMetadata ()
Returns the bubble metadata that will be used to display app content in a floating window over the existing foreground activity.
Returns | |
---|---|
Notification.BubbleMetadata |
This value may be null . |
public String getChannelId ()
Returns the id of the channel this notification posts to.
Returns | |
---|---|
String |
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 . |
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 |
public int getGroupAlertBehavior ()
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
.
Returns | |
---|---|
int |
Value is GROUP_ALERT_ALL , GROUP_ALERT_CHILDREN , or GROUP_ALERT_SUMMARY |
public Icon getLargeIcon ()
The large icon shown in this notification's content view.
Returns | |
---|---|
Icon |
public LocusId getLocusId ()
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.
Returns | |
---|---|
LocusId |
This value may be null . |
public CharSequence getSettingsText ()
Returns the settings text provided to Builder#setSettingsText(CharSequence)
.
Returns | |
---|---|
CharSequence |
public String getShortcutId ()
Returns the ShortcutInfo#getId()
that this notification supersedes, if any.
Used by some Launchers that display notification content to hide shortcuts that duplicate notifications.
Returns | |
---|---|
String |
public Icon getSmallIcon ()
The small icon representing this notification in the status bar and content view.
Returns | |
---|---|
Icon |
the small icon representing this notification. |
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
.
Returns | |
---|---|
String |
See also:
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 |
public String toString ()
Returns a string representation of the object. In general, the
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Returns | |
---|---|
String |
a string representation of the object. |
public void writeToParcel (Parcel parcel, int flags)
Flatten this notification into a parcel.
Parameters | |
---|---|
parcel |
Parcel : The Parcel in which the object should be written. |
flags |
int : Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE .
Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |