Google 致力于为黑人社区推动种族平等。查看具体举措

NotificationCompat

open class NotificationCompat
kotlin.Any
   ↳ androidx.core.app.NotificationCompat

Helper for accessing features in android.app.Notification.

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

Helper class to add Android Auto extensions to notifications.

open

Notification style for 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

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 wearable extensions to notifications.

Constants
static Int

If this notification is being shown as a badge, use the icon provided to Builder#setLargeIcon(Bitmap) 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 icon provided to Builder#setSmallIcon(int) 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: 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: tracking a user's workout.

static Int

Value of Notification#color equal to 0 (also known as Color.TRANSPARENT), telling the system not to decorate this notification with any special color but instead use default colors when presenting this notification.

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

Keys into the getExtras Bundle: the audio contents of this notification.

static String

extras key: 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

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 string representing the name of the specific NotificationCompat.Style used to create this notification.

static String

extras key: a String to be displayed as the title to a conversation represented by a MessagingStyle.

static String

Key for compat's MessagingStyle#getConversationTitle().

static String

extras key: an array of historic MessagingStyle.Message bundles provided by a 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 NotificationCompat.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

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

static String

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

static String

extras key: the person to display for all messages sent by the user, including direct replies to MessagingStyle notifications.

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, each of which was supplied to Builder#addPerson(Person).

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

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

static String

extras key: whether the when field set using Builder#setWhen 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 the when field set using Builder#setWhen 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 Int

Bit set in the Notification flags field if the notification should be canceled when it is clicked by the user.

static Int

Bit set in the Notification flags field if this notification is showing as a bubble.

static Int

Bit set in the Notification flags field if this notification represents a currently running service.

static Int

Bit set in the Notification flags field 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 set in the Notification flags field if the audio will be repeated until the notification is cancelled or the notification window is opened.

static Int

Bit set in the Notification flags field if this notification is relevant to the current device only and it is not recommended that it bridge to other devices.

static Int

Bit set in the Notification flags field if the notification should not be canceled when the user clicks the Clear all button.

static Int

Bit set in the Notification flags field if this notification is in reference to something that is ongoing, like a phone call.

static Int

Bit set in the Notification flags field if the notification's sound, vibrate and ticker should only be played if the notification is not already showing.

static Int

Bit set in the Notification flags field when LEDs should be turned on for this notification.

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 would otherwise make sound or vibrate.

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 would otherwise make sound or vibrate.

static String

Constant for the group key that's added to notifications that are not already grouped when Builder#setNotificationSilent() is used when Build.VERSION#SDK_INT is >= Build.VERSION_CODES#O.

static String

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

static Int

Default notification priority for NotificationCompat.Builder#setPriority(int).

static Int

Higher notification priority for NotificationCompat.Builder#setPriority(int), for more important notifications or alerts.

static Int

Lower notification priority for NotificationCompat.Builder#setPriority(int), for items that are less important.

static Int

Highest notification priority for NotificationCompat.Builder#setPriority(int), for your application's most important items that require the user's prompt attention or input.

static Int

Lowest notification priority for NotificationCompat.Builder#setPriority(int); these items might not be shown to the user except under special circumstances, such as detailed notification logs.

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.

static Int

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

Public constructors

Public methods
open static NotificationCompat.Action?
getAction(@NonNull notification: Notification, actionIndex: Int)

Get an action on this notification in a backwards compatible manner.

open static Int
getActionCount(@NonNull notification: Notification)

Get the number of actions in this notification in a backwards compatible manner.

open static Boolean

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

open static Boolean
getAutoCancel(@NonNull notification: Notification)

Get the value provided to Builder#setAutoCancel(boolean)

open static Int
getBadgeIconType(@NonNull notification: Notification)

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

open static NotificationCompat.BubbleMetadata?
getBubbleMetadata(@NonNull notification: Notification)

Get the BubbleMetadata for a notification that will be used to display app content in a floating window over the existing foreground activity.

open static String?
getCategory(@NonNull notification: Notification)

Get the category of this notification in a backwards compatible manner.

open static String?
getChannelId(@NonNull notification: Notification)

open static Int
getColor(@NonNull notification