public class Notification extends Object implements Parcelable
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.
Modifier and Type | Class and Description |
---|---|
static class |
Notification.Action
Structure to encapsulate a named action that can be shown as part of this notification.
|
static class |
Notification.BigPictureStyle
Helper class for generating large-format notifications that include a large image attachment.
|
static class |
Notification.BigTextStyle
Helper class for generating large-format notifications that include a lot of text.
|
static class |
Notification.Builder
Builder class for
Notification objects. |
static class |
Notification.CarExtender
Helper class to add Android Auto extensions to notifications.
|
static 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.
|
static 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.
|
static interface |
Notification.Extender
Extender interface for use with
Notification.Action.Builder.extend(android.app.Notification.Action.Extender) . |
static class |
Notification.InboxStyle
Helper class for generating large-format notifications that include a list of (up to 5) strings.
|
static class |
Notification.MediaStyle
Notification style for media playback notifications.
|
static 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.
|
static interface |
Notification.Priority |
static class |
Notification.Style
An object that can apply a rich notification style to a
Notification.Builder
object. |
static class |
Notification.WearableExtender
Helper class to add wearable extensions to notifications.
|
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
Notification.Action[] |
actions
Array of all
Notification.Action structures attached to this notification by
Builder#addAction(int, CharSequence, PendingIntent) . |
ArraySet<PendingIntent> |
allPendingIntents
All pending intents in the notification as the system needs to be able to access them but
touching the extras bundle in the system process is not safe because the bundle may contain
custom parcelable objects.
|
static AudioAttributes |
AUDIO_ATTRIBUTES_DEFAULT
The default value of
audioAttributes . |
AudioAttributes |
audioAttributes
The
audio attributes to use when playing the sound. |
int |
audioStreamType
Deprecated.
Use
audioAttributes instead. |
RemoteViews |
bigContentView
Deprecated.
|
String |
category
One of the predefined notification categories (see the
CATEGORY_* constants)
that best describes this Notification. |
static String |
CATEGORY_ALARM
Notification category: alarm or timer.
|
static String |
CATEGORY_CALL
Notification category: incoming call (voice or video) or similar synchronous communication request.
|
static String |
CATEGORY_EMAIL
Notification category: asynchronous bulk message (email).
|
static String |
CATEGORY_ERROR
Notification category: error in background operation or authentication status.
|
static String |
CATEGORY_EVENT
Notification category: calendar event.
|
static String |
CATEGORY_MESSAGE
Notification category: incoming direct message (SMS, instant message, etc.).
|
static String |
CATEGORY_PROGRESS
Notification category: progress of a long-running background operation.
|
static String |
CATEGORY_PROMO
Notification category: promotion or advertisement.
|
static String |
CATEGORY_RECOMMENDATION
Notification category: a specific, timely recommendation for a single thing.
|
static String |
CATEGORY_REMINDER
Notification category: user-scheduled reminder.
|
static String |
CATEGORY_SERVICE
Notification category: indication of running background service.
|
static String |
CATEGORY_SOCIAL
Notification category: social network or sharing update.
|
static String |
CATEGORY_STATUS
Notification category: ongoing information about device or contextual status.
|
static String |
CATEGORY_SYSTEM
Notification category: system or device status update.
|
static String |
CATEGORY_TRANSPORT
Notification category: media transport control for playback.
|
int |
color
Accent color (an ARGB integer like the constants in
Color )
to be applied by the standard Style templates when presenting this notification. |
static 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. |
PendingIntent |
contentIntent
The intent to execute when the expanded status entry is clicked.
|
RemoteViews |
contentView
Deprecated.
|
static Parcelable.Creator<Notification> |
CREATOR
Parcelable.Creator that instantiates Notification objects
|
static int |
DEFAULT_ALL
Use all default values (where applicable).
|
static int |
DEFAULT_LIGHTS
Use the default notification lights.
|
static int |
DEFAULT_SOUND
Use the default notification sound.
|
static int |
DEFAULT_VIBRATE
Use the default notification vibrate.
|
int |
defaults
Specifies which values should be taken from the defaults.
|
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.
|
static String |
EXTRA_ALLOW_DURING_SETUP
Allow certain system-generated notifications to appear before the device is provisioned.
|
static String |
EXTRA_BACKGROUND_IMAGE_URI
extras key: A
content URI pointing to an image that can be displayed
in the background when the notification is selected. |
static String |
EXTRA_BIG_TEXT
extras key: this is the longer text shown in the big form of a
Notification.BigTextStyle notification, as supplied to
Notification.BigTextStyle.bigText(CharSequence) . |
static String |
EXTRA_BUILDER_APPLICATION_INFO |
static String |
EXTRA_CHRONOMETER_COUNT_DOWN
extras key: whether the chronometer set on the notification should count down
instead of counting up. |
static String |
EXTRA_COMPACT_ACTIONS
extras key: the indices of actions to be shown in the compact view,
as supplied to (e.g.) |
static String |
EXTRA_CONTAINS_CUSTOM_VIEW |
static String |
EXTRA_CONVERSATION_TITLE
extras key: a CharSequence to be displayed as the title to a conversation
represented by a Notification.MessagingStyle |
static String |
EXTRA_INFO_TEXT
extras key: this is a small piece of additional text as supplied to
Builder#setContentInfo(CharSequence) . |
static String |
EXTRA_LARGE_ICON
extras key: this is a bitmap to be used instead of the small icon when showing the
notification payload, as
supplied to Builder#setLargeIcon(android.graphics.Bitmap) . |
static 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
Notification.BigPictureStyle.bigLargeIcon(android.graphics.Bitmap) . |
static String |
EXTRA_MEDIA_SESSION
|
static String |
EXTRA_MESSAGES
extras key: an array of Notification.MessagingStyle.Message
bundles provided by a
Notification.MessagingStyle notification. |
static String |
EXTRA_ORIGINATING_USERID
extras key: the user that built the notification. |
static String |
EXTRA_PEOPLE
extras key: A String array containing the people that this notification relates to,
each of which was supplied to Builder#addPerson(String) . |
static String |
EXTRA_PICTURE
extras key: this is a bitmap to be shown in Notification.BigPictureStyle expanded
notifications, supplied to Notification.BigPictureStyle.bigPicture(android.graphics.Bitmap) . |
static String |
EXTRA_PROGRESS
extras key: this is the progress value supplied to
Builder#setProgress(int, int, boolean) . |
static String |
EXTRA_PROGRESS_INDETERMINATE
extras key: whether the progress bar is indeterminate, supplied to
Builder#setProgress(int, int, boolean) . |
static String |
EXTRA_PROGRESS_MAX
extras key: this is the maximum value supplied to
Builder#setProgress(int, int, boolean) . |
static String |
EXTRA_REMOTE_INPUT_HISTORY
extras key: this is the remote input history, as supplied to
Builder#setRemoteInputHistory(CharSequence[]) . |
static String |
EXTRA_SELF_DISPLAY_NAME
extras key: the username to be displayed for all messages sent by the user including
direct replies
Notification.MessagingStyle notification. |
static 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) . |
static String |
EXTRA_SHOW_WHEN
|
static String |
EXTRA_SMALL_ICON
extras key: this is the resource ID of the notification's main small icon, as
supplied to Builder#setSmallIcon(int) . |
static String |
EXTRA_SUB_TEXT
extras key: this is a third line of text, as supplied to
Builder#setSubText(CharSequence) . |
static String |
EXTRA_SUBSTITUTE_APP_NAME |
static 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.) |
static String |
EXTRA_TEMPLATE
extras key: A string representing the name of the specific
Notification.Style used to create this notification. |
static String |
EXTRA_TEXT
extras key: this is the main text payload, as supplied to
Builder#setContentText(CharSequence) . |
static String |
EXTRA_TEXT_LINES
extras key: An array of CharSequences to show in Notification.InboxStyle expanded
notifications, each of which was supplied to Notification.InboxStyle.addLine(CharSequence) . |
static String |
EXTRA_TITLE
extras key: this is the title of the notification,
as supplied to Builder#setContentTitle(CharSequence) . |
static String |
EXTRA_TITLE_BIG
extras key: this is the title of the notification when shown in expanded form,
e.g. as supplied to Notification.BigTextStyle.setBigContentTitle(CharSequence) . |
Bundle |
extras
Additional semantic data to be carried around with this Notification.
|
static 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. |
static int |
FLAG_AUTOGROUP_SUMMARY
Bit to be bitswise-ored into the
flags field that should be
set if this notification is the group summary for an auto-group of notifications. |
static 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. |
static 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. |
static int |
FLAG_HIGH_PRIORITY
Deprecated.
Use
priority with a positive value. |
static 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. |
static 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. |
static 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. |
static 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. |
static 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. |
static int |
FLAG_SHOW_LIGHTS
Bit to be bitwise-ored into the
flags field that should be
set if you want the LED on for this notification. |
int |
flags |
PendingIntent |
fullScreenIntent
An intent to launch instead of posting the notification to the status bar.
|
RemoteViews |
headsUpContentView
Deprecated.
|
int |
icon
Deprecated.
Use
setSmallIcon(Icon) instead. |
int |
iconLevel
If the icon in the status bar is to have more than one level, you can set this.
|
static String |
INTENT_CATEGORY_NOTIFICATION_PREFERENCES
An activity that provides a user interface for adjusting notification preferences for its
containing application.
|
Bitmap |
largeIcon
Deprecated.
Use
Builder#setLargeIcon(Icon) instead. |
int |
ledARGB
The color of the led.
|
int |
ledOffMS
The number of milliseconds for the LED to be off while it's flashing.
|
int |
ledOnMS
The number of milliseconds for the LED to be on while it's flashing.
|
int |
number
Deprecated.
this number is not shown anymore
|
int |
priority
Relative priority for this notification.
|
static int |
PRIORITY_DEFAULT
Default notification
priority . |
static int |
PRIORITY_HIGH
Higher
priority , for more important notifications or alerts. |
static int |
PRIORITY_LOW
Lower
priority , for items that are less important. |
static int |
PRIORITY_MAX
Highest
priority , for your application's most important items that require the
user's prompt attention or input. |
static int |
PRIORITY_MIN
Lowest
priority ; these items might not be shown to the user except under special
circumstances, such as detailed notification logs. |
Notification |
publicVersion
Replacement version of this notification whose content will be shown
in an insecure context such as atop a secure keyguard.
|
Uri |
sound
The sound to play.
|
static int |
STREAM_DEFAULT
Deprecated.
Use
audioAttributes instead. |
CharSequence |
tickerText
Text that summarizes this notification for accessibility services.
|
RemoteViews |
tickerView
Deprecated.
|
long[] |
vibrate
The pattern with which to vibrate.
|
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).
|
static int |
VISIBILITY_PRIVATE
Notification visibility: Show this notification on all lockscreens, but conceal sensitive or
private information on secure lockscreens.
|
static int |
VISIBILITY_PUBLIC
Notification visibility: Show this notification in its entirety on all lockscreens.
|
static int |
VISIBILITY_SECRET
Notification visibility: Do not reveal any part of this notification on a secure lockscreen.
|
long |
when
A timestamp related to this notification, in milliseconds since the epoch.
|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
Notification()
Constructs a Notification object with default values.
|
Notification(Context context,
int icon,
CharSequence tickerText,
long when,
CharSequence contentTitle,
CharSequence contentText,
Intent contentIntent) |
Notification(int icon,
CharSequence tickerText,
long when)
Deprecated.
Use
Notification.Action.Builder instead. |
Notification(Parcel parcel)
Unflatten the notification from a parcel.
|
Modifier and Type | Method and Description |
---|---|
static void |
addFieldsFromContext(ApplicationInfo ai,
int userId,
Notification notification) |
static void |
addFieldsFromContext(Context context,
Notification notification) |
Notification |
clone()
Creates and returns a copy of this object.
|
void |
cloneInto(Notification that,
boolean heavy)
Copy all (or if heavy is false, all except Bitmaps and RemoteViews) members
of this into that.
|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
String |
getGroup()
Get the key used to group this notification into a cluster or stack
with other notifications on devices which support such rendering.
|
Icon |
getLargeIcon()
The large icon shown in this notification's content view.
|
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.
|
boolean |
isGroupChild() |
boolean |
isGroupSummary() |
void |
lightenPayload()
Removes heavyweight parts of the Notification object for archival or for sending to
listeners when the full contents are not necessary.
|
static String |
priorityToString(int pri) |
static CharSequence |
safeCharSequence(CharSequence cs)
Make sure this CharSequence is safe to put into a bundle, which basically
means it had better not be some custom Parcelable implementation.
|
void |
setLatestEventInfo(Context context,
CharSequence contentTitle,
CharSequence contentText,
PendingIntent contentIntent)
Deprecated.
Use
Notification.Action.Builder instead. |
void |
setSmallIcon(Icon icon)
Used when notifying to clean up legacy small icons.
|
boolean |
showsChronometer() |
boolean |
showsTime() |
String |
toString()
Returns a string representation of the object.
|
static String |
visibilityToString(int vis) |
void |
writeToParcel(Parcel parcel,
int flags)
Flatten this notification into a parcel.
|
public static final String INTENT_CATEGORY_NOTIFICATION_PREFERENCES
Notifications
.public static final int DEFAULT_ALL
public static final int DEFAULT_SOUND
sound
.
A notification that is noisy is more likely to be presented as a heads-up notification.
defaults
,
Constant Field Valuespublic static final int DEFAULT_VIBRATE
vibrate
. Using phone vibration requires the
VIBRATE
permission.
A notification that vibrates is more likely to be presented as a heads-up notification.
defaults
,
Constant Field Valuespublic static final int DEFAULT_LIGHTS
FLAG_SHOW_LIGHTS
bit, and ledARGB
, ledOffMS
, or
ledOnMS
.defaults
,
Constant Field Valuespublic long when
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:
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)
@Deprecated @DrawableRes public int icon
setSmallIcon(Icon)
instead.public int iconLevel
public int number
Build.VERSION_CODES.HONEYCOMB
, this number was
superimposed over the icon in the status bar. Starting with
Build.VERSION_CODES.HONEYCOMB
, the template used by
Notification.Builder
has displayed the number in the expanded notification view.
If the number is 0 or negative, it is never shown.public PendingIntent contentIntent
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 PendingIntent deleteIntent
public PendingIntent fullScreenIntent
The system UI may choose to display a heads-up notification, instead of launching this intent, while the user is using the device.
public CharSequence tickerText
tickerView
@Deprecated public RemoteViews tickerView
tickerText
.
No longer displayed in the status bar as of API 21.@Deprecated public RemoteViews contentView
Notification.Builder
; a custom RemoteViews can optionally be
supplied with Notification.Builder.setCustomContentView(RemoteViews)
.@Deprecated public RemoteViews bigContentView
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)
.@Deprecated public RemoteViews headsUpContentView
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)
.@Deprecated public Bitmap largeIcon
Builder#setLargeIcon(Icon)
instead.public Uri sound
A notification that is noisy is more likely to be presented as a heads-up notification.
To play the default notification sound, see defaults
.
@Deprecated public static final int STREAM_DEFAULT
audioAttributes
instead.AudioManager.STREAM_NOTIFICATION
.@Deprecated public int audioStreamType
audioAttributes
instead.AudioManager
.public static final AudioAttributes AUDIO_ATTRIBUTES_DEFAULT
audioAttributes
.public AudioAttributes audioAttributes
audio attributes
to use when playing the sound.public long[] vibrate
To vibrate the default pattern, see defaults
.
A notification that vibrates is more likely to be presented as a heads-up notification.
Vibrator.vibrate(long[],int)
public int ledARGB
FLAG_SHOW_LIGHTS
,
flags
public int ledOnMS
FLAG_SHOW_LIGHTS
,
flags
public int ledOffMS
FLAG_SHOW_LIGHTS
,
flags
public int defaults
To set, OR the desired from DEFAULT_SOUND
,
DEFAULT_VIBRATE
, DEFAULT_LIGHTS
. For all default
values, use DEFAULT_ALL
.
public static final int FLAG_SHOW_LIGHTS
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 (TODO) if possible because they will be set to values that work on any given hardware.
The alpha channel must be set for forward compatibility.
public static final int FLAG_ONGOING_EVENT
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.public static final int FLAG_INSISTENT
flags
field that if set,
the audio will be repeated until the notification is
cancelled or the notification window is opened.public static final int FLAG_ONLY_ALERT_ONCE
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.public static final int FLAG_AUTO_CANCEL
flags
field that should be
set if the notification should be canceled when it is clicked by the
user.public static final int FLAG_NO_CLEAR
flags
field that should be
set if the notification should not be canceled when the user clicks
the Clear all button.public static final int FLAG_FOREGROUND_SERVICE
flags
field that should be
set if this notification represents a currently running service. This
will normally be set for you by Service.startForeground(int, android.app.Notification)
.public static final int FLAG_HIGH_PRIORITY
priority
with a positive value.public static final int FLAG_LOCAL_ONLY
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.public static final int FLAG_GROUP_SUMMARY
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
.public static final int FLAG_AUTOGROUP_SUMMARY
flags
field that should be
set if this notification is the group summary for an auto-group of notifications.public int flags
public static final int PRIORITY_DEFAULT
priority
. If your application does not prioritize its own
notifications, use this value for all notifications.public static final int PRIORITY_LOW
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.public static final int PRIORITY_MIN
priority
; these items might not be shown to the user except under special
circumstances, such as detailed notification logs.public static final int PRIORITY_HIGH
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.public static final int PRIORITY_MAX
priority
, for your application's most important items that require the
user's prompt attention or input.public int priority
A notification that is at least PRIORITY_HIGH
is more likely to be presented
as a heads-up notification.
public int color
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 static final int COLOR_DEFAULT
color
telling the system not to decorate this notification with
any special color but instead use default colors when presenting this notification.public int visibility
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.public static final int VISIBILITY_PUBLIC
visibility
public static final int VISIBILITY_PRIVATE
visibility
public static final int VISIBILITY_SECRET
visibility
public static final String CATEGORY_CALL
public static final String CATEGORY_MESSAGE
public static final String CATEGORY_EMAIL
public static final String CATEGORY_EVENT
public static final String CATEGORY_PROMO
public static final String CATEGORY_ALARM
public static final String CATEGORY_PROGRESS
public static final String CATEGORY_SOCIAL
public static final String CATEGORY_ERROR
public static final String CATEGORY_TRANSPORT
public static final String CATEGORY_SYSTEM
public static final String CATEGORY_SERVICE
public static final String CATEGORY_RECOMMENDATION
public static final String CATEGORY_STATUS
public static final String CATEGORY_REMINDER
public String category
CATEGORY_*
constants)
that best describes this Notification. May be used by the system for ranking and filtering.public Bundle extras
The extras keys defined here are intended to capture the original inputs to Notification.Action.Builder
APIs, and are intended to be used by
NotificationListenerService
implementations to extract
detailed information from notification objects.
public ArraySet<PendingIntent> allPendingIntents
public static final String EXTRA_TITLE
extras
key: this is the title of the notification,
as supplied to Builder#setContentTitle(CharSequence)
.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 Notification.BigTextStyle.setBigContentTitle(CharSequence)
.public static final String EXTRA_TEXT
extras
key: this is the main text payload, as supplied to
Builder#setContentText(CharSequence)
.public static final String EXTRA_SUB_TEXT
extras
key: this is a third line of text, as supplied to
Builder#setSubText(CharSequence)
.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.Builder#setRemoteInputHistory(CharSequence[])
,
Constant Field Valuespublic static final String EXTRA_INFO_TEXT
extras
key: this is a small piece of additional text as supplied to
Builder#setContentInfo(CharSequence)
.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.)
Notification.BigTextStyle.setSummaryText(CharSequence)
.public static final String EXTRA_BIG_TEXT
extras
key: this is the longer text shown in the big form of a
Notification.BigTextStyle
notification, as supplied to
Notification.BigTextStyle.bigText(CharSequence)
.public static final String EXTRA_SMALL_ICON
extras
key: this is the resource ID of the notification's main small icon, as
supplied to Builder#setSmallIcon(int)
.public static final String EXTRA_LARGE_ICON
extras
key: this is a bitmap to be used instead of the small icon when showing the
notification payload, as
supplied to Builder#setLargeIcon(android.graphics.Bitmap)
.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
Notification.BigPictureStyle.bigLargeIcon(android.graphics.Bitmap)
.public static final String EXTRA_PROGRESS
extras
key: this is the progress value supplied to
Builder#setProgress(int, int, boolean)
.public static final String EXTRA_PROGRESS_MAX
extras
key: this is the maximum value supplied to
Builder#setProgress(int, int, boolean)
.public static final String EXTRA_PROGRESS_INDETERMINATE
extras
key: whether the progress bar is indeterminate, supplied to
Builder#setProgress(int, int, boolean)
.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)
.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.public static final String EXTRA_SHOW_WHEN
public static final String EXTRA_PICTURE
extras
key: this is a bitmap to be shown in Notification.BigPictureStyle
expanded
notifications, supplied to Notification.BigPictureStyle.bigPicture(android.graphics.Bitmap)
.public static final String EXTRA_TEXT_LINES
extras
key: An array of CharSequences to show in Notification.InboxStyle
expanded
notifications, each of which was supplied to Notification.InboxStyle.addLine(CharSequence)
.public static final String EXTRA_TEMPLATE
extras
key: A string representing the name of the specific
Notification.Style
used to create this notification.public static final String EXTRA_PEOPLE
extras
key: A String array containing the people that this notification relates to,
each of which was supplied to Builder#addPerson(String)
.public static final String EXTRA_ALLOW_DURING_SETUP
public static final String EXTRA_BACKGROUND_IMAGE_URI
extras
key: A
content URI
pointing to an image that can be displayed
in the background when the notification is selected. The URI must point to an image stream
suitable for passing into
BitmapFactory.decodeStream
; all other content types will be ignored. The content provider
URI used for this purpose must require no permissions to read the image data.public static final String EXTRA_MEDIA_SESSION
public static final String EXTRA_COMPACT_ACTIONS
extras
key: the indices of actions to be shown in the compact view,
as supplied to (e.g.) Notification.MediaStyle.setShowActionsInCompactView(int...)
.public static final String EXTRA_SELF_DISPLAY_NAME
extras
key: the username to be displayed for all messages sent by the user including
direct replies
Notification.MessagingStyle
notification. This extra is a
CharSequence
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
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.public static final String EXTRA_ORIGINATING_USERID
extras
key: the user that built the notification.public static final String EXTRA_BUILDER_APPLICATION_INFO
public static final String EXTRA_CONTAINS_CUSTOM_VIEW
public static final String EXTRA_SUBSTITUTE_APP_NAME
public Notification.Action[] actions
Notification.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 Notification publicVersion
visibility
and VISIBILITY_PUBLIC
.public static final Parcelable.Creator<Notification> CREATOR
public Notification()
Notification.Action.Builder
instead.public Notification(Context context, int icon, CharSequence tickerText, long when, CharSequence contentTitle, CharSequence contentText, Intent contentIntent)
@Deprecated public Notification(int icon, CharSequence tickerText, long when)
Notification.Action.Builder
instead.icon
- The resource id of the icon to put in the status bar.tickerText
- The text that flows by in the status bar when the notification first
activates.when
- The time to show in the time field. In the System.currentTimeMillis
timebase.public Notification(Parcel parcel)
public String getGroup()
public String getSortKey()
This sort key can also be used to order members of a notification group. See
Builder#setGroup
.
String.compareTo(String)
public Notification clone()
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.
public void cloneInto(Notification that, boolean heavy)
public final void lightenPayload()
public static CharSequence safeCharSequence(CharSequence cs)
public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel parcel, int flags)
writeToParcel
in interface Parcelable
parcel
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.@Deprecated public void setLatestEventInfo(Context context, CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent)
Notification.Action.Builder
instead.contentView
field to be a view with the standard "Latest Event"
layout.
Uses the icon
and when
fields to set the icon and time fields
in the view.
context
- The context for your application / activity.contentTitle
- The title that goes in the expanded entry.contentText
- The text that goes in the expanded entry.contentIntent
- The intent to launch when the user clicks the expanded notification.
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.public static void addFieldsFromContext(Context context, Notification notification)
public static void addFieldsFromContext(ApplicationInfo ai, int userId, Notification notification)
public String toString()
Object
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())
public static String visibilityToString(int vis)
public static String priorityToString(int pri)
public Icon getSmallIcon()
getSmallIcon()
,
setSmallIcon(Icon)
public void setSmallIcon(Icon icon)
public Icon getLargeIcon()
getLargeIcon()
,
Builder#setLargeIcon(Icon)
public boolean isGroupSummary()
public boolean isGroupChild()
public boolean showsTime()
public boolean showsChronometer()