NotificationCompat.Action

Added in 1.1.0

class NotificationCompat.Action


Structure to encapsulate a named action that can be shown as part of this notification. It must include an icon, a label, and a PendingIntent to be fired when the action is selected by the user. Action buttons won't appear on platforms prior to Android JELLY_BEAN.

As of Android N, action button icons will not be displayed on action buttons, but are still required and are available to notification listeners, which may display them in other contexts, for example on a wearable device.

Apps should use addAction or addAction to attach actions.

Summary

Nested types

Builder class for Action objects.

Extender interface for use with extend.

@IntDef(value = )
@Retention(value = RetentionPolicy.SOURCE)
annotation NotificationCompat.Action.SemanticAction

Provides meaning to an Action that hints at what the associated PendingIntent will do.

Wearable extender for notification actions.

Constants

const Int

SemanticAction: Archive the content associated with the notification.

const Int

SemanticAction: Call a contact, group, etc.

const Int

SemanticAction: Delete the content associated with the notification.

const Int

SemanticAction: Mark content as read.

const Int

SemanticAction: Mark content as unread.

const Int

SemanticAction: Mute the content associated with the notification.

const Int

SemanticAction: No semantic action defined.

const Int

SemanticAction: Reply to a conversation, chat, group, or wherever replies may be appropriate.

const Int

SemanticAction: Mark content with a thumbs down.

const Int

SemanticAction: Mark content with a thumbs up.

const Int

SemanticAction: Unmute the content associated with the notification.

Public constructors

Action(icon: IconCompat?, title: CharSequence?, intent: PendingIntent?)

Note: For devices running an Android version strictly lower than API level 23 this constructor only supports resource-ID based IconCompat objects.

Action(icon: Int, title: CharSequence?, intent: PendingIntent?)

Public functions

PendingIntent?
Boolean

Return whether the platform should automatically generate possible replies for this Action

Array<RemoteInput!>?

Get the list of inputs to be collected from the user that ONLY accept data when this action is sent.

Bundle

Get additional metadata carried around with this Action.

Int

This function is deprecated.

use getIconCompat instead.

IconCompat?

Return the icon associated with this Action.

Array<RemoteInput!>?

Get the list of inputs to be collected from the user when this action is sent.

Int

Returns the SemanticAction associated with this Action.

Boolean

Return whether or not triggering this Action's PendingIntent will open a user interface.

CharSequence?
Boolean

Returns whether the OS should only send this action's PendingIntent on an unlocked device.

Boolean

Returns whether this is a contextual Action, i.e. whether the action is dependent on the notification message body.

Public properties

PendingIntent?

Intent to send when the user invokes this action.

Int

This property is deprecated.

Use getIconCompat instead.

CharSequence!

Title of the action.

Constants

SEMANTIC_ACTION_ARCHIVE

Added in 1.1.0
const val SEMANTIC_ACTION_ARCHIVE = 5: Int

SemanticAction: Archive the content associated with the notification. This could mean archiving an email, message, etc.

SEMANTIC_ACTION_CALL

Added in 1.1.0
const val SEMANTIC_ACTION_CALL = 10: Int

SemanticAction: Call a contact, group, etc.

SEMANTIC_ACTION_DELETE

Added in 1.1.0
const val SEMANTIC_ACTION_DELETE = 4: Int

SemanticAction: Delete the content associated with the notification. This could mean deleting an email, message, etc.

SEMANTIC_ACTION_MARK_AS_READ

Added in 1.1.0
const val SEMANTIC_ACTION_MARK_AS_READ = 2: Int

SemanticAction: Mark content as read.

SEMANTIC_ACTION_MARK_AS_UNREAD

Added in 1.1.0
const val SEMANTIC_ACTION_MARK_AS_UNREAD = 3: Int

SemanticAction: Mark content as unread.

SEMANTIC_ACTION_MUTE

Added in 1.1.0
const val SEMANTIC_ACTION_MUTE = 6: Int

SemanticAction: Mute the content associated with the notification. This could mean silencing a conversation or currently playing media.

SEMANTIC_ACTION_NONE

Added in 1.1.0
const val SEMANTIC_ACTION_NONE = 0: Int

SemanticAction: No semantic action defined.

SEMANTIC_ACTION_REPLY

Added in 1.1.0
const val SEMANTIC_ACTION_REPLY = 1: Int

SemanticAction: Reply to a conversation, chat, group, or wherever replies may be appropriate.

SEMANTIC_ACTION_THUMBS_DOWN

Added in 1.1.0
const val SEMANTIC_ACTION_THUMBS_DOWN = 9: Int

SemanticAction: Mark content with a thumbs down.

SEMANTIC_ACTION_THUMBS_UP

Added in 1.1.0
const val SEMANTIC_ACTION_THUMBS_UP = 8: Int

SemanticAction: Mark content with a thumbs up.

SEMANTIC_ACTION_UNMUTE

Added in 1.1.0
const val SEMANTIC_ACTION_UNMUTE = 7: Int

SemanticAction: Unmute the content associated with the notification. This could mean un-silencing a conversation or currently playing media.

Public constructors

Action

Added in 1.2.0
Action(icon: IconCompat?, title: CharSequence?, intent: PendingIntent?)

Note: For devices running an Android version strictly lower than API level 23 this constructor only supports resource-ID based IconCompat objects.

Action

Added in 1.1.0
Action(icon: Int, title: CharSequence?, intent: PendingIntent?)

Public functions

getActionIntent

Added in 1.1.0
fun getActionIntent(): PendingIntent?

getAllowGeneratedReplies

Added in 1.1.0
fun getAllowGeneratedReplies(): Boolean

Return whether the platform should automatically generate possible replies for this Action

getDataOnlyRemoteInputs

Added in 1.1.0
fun getDataOnlyRemoteInputs(): Array<RemoteInput!>?

Get the list of inputs to be collected from the user that ONLY accept data when this action is sent. These remote inputs are guaranteed to return true on a call to isDataOnly.

May return null if no data-only remote inputs were added.

This method exists so that legacy RemoteInput collectors that pre-date the addition of non-textual RemoteInputs do not access these remote inputs.

getExtras

Added in 1.1.0
fun getExtras(): Bundle

Get additional metadata carried around with this Action.

getIcon

Added in 1.1.0
Deprecated in 1.2.0
fun getIcon(): Int

getIconCompat

Added in 1.2.0
fun getIconCompat(): IconCompat?

Return the icon associated with this Action.

getRemoteInputs

Added in 1.1.0
fun getRemoteInputs(): Array<RemoteInput!>?

Get the list of inputs to be collected from the user when this action is sent. May return null if no remote inputs were added. Only returns inputs which accept a text input. For inputs which only accept data use getDataOnlyRemoteInputs.

getSemanticAction

Added in 1.1.0
@NotificationCompat.Action.SemanticAction
fun getSemanticAction(): Int

Returns the SemanticAction associated with this Action. A SemanticAction denotes what an Action's PendingIntent will do (eg. reply, mark as read, delete, etc).

getShowsUserInterface

Added in 1.1.0
fun getShowsUserInterface(): Boolean

Return whether or not triggering this Action's PendingIntent will open a user interface.

getTitle

Added in 1.1.0
fun getTitle(): CharSequence?

isAuthenticationRequired

Added in 1.8.0
fun isAuthenticationRequired(): Boolean

Returns whether the OS should only send this action's PendingIntent on an unlocked device. If the device is locked when the action is invoked, the OS should show the keyguard and require successful authentication before invoking the intent.

isContextual

Added in 1.2.0
fun isContextual(): Boolean

Returns whether this is a contextual Action, i.e. whether the action is dependent on the notification message body. An example of a contextual action could be an action opening a map application with an address shown in the notification.

Public properties

actionIntent

Added in 1.1.0
val actionIntentPendingIntent?

Intent to send when the user invokes this action. May be null, in which case the action may be rendered in a disabled presentation.

icon

Added in 1.1.0
Deprecated in 1.2.0
val iconInt

Small icon representing the action.

title

Added in 1.1.0
val titleCharSequence!

Title of the action.