public class

NotificationCompat.Action

extends java.lang.Object

 java.lang.Object

↳androidx.core.app.NotificationCompat.Action

Overview

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 .

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

Apps should use NotificationCompat.Builder.addAction(int, CharSequence, PendingIntent) or NotificationCompat.Builder.addAction(NotificationCompat.Action) to attach actions.

Summary

Fields
public PendingIntentactionIntent

Intent to send when the user invokes this action.

public inticon

Small icon representing the action.

public static final intSEMANTIC_ACTION_ARCHIVE

NotificationCompat.Action.SemanticAction: Archive the content associated with the notification.

public static final intSEMANTIC_ACTION_CALL

NotificationCompat.Action.SemanticAction: Call a contact, group, etc.

public static final intSEMANTIC_ACTION_DELETE

NotificationCompat.Action.SemanticAction: Delete the content associated with the notification.

public static final intSEMANTIC_ACTION_MARK_AS_READ

NotificationCompat.Action.SemanticAction: Mark content as read.

public static final intSEMANTIC_ACTION_MARK_AS_UNREAD

NotificationCompat.Action.SemanticAction: Mark content as unread.

public static final intSEMANTIC_ACTION_MUTE

NotificationCompat.Action.SemanticAction: Mute the content associated with the notification.

public static final intSEMANTIC_ACTION_NONE

NotificationCompat.Action.SemanticAction: No semantic action defined.

public static final intSEMANTIC_ACTION_REPLY

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

public static final intSEMANTIC_ACTION_THUMBS_DOWN

NotificationCompat.Action.SemanticAction: Mark content with a thumbs down.

public static final intSEMANTIC_ACTION_THUMBS_UP

NotificationCompat.Action.SemanticAction: Mark content with a thumbs up.

public static final intSEMANTIC_ACTION_UNMUTE

NotificationCompat.Action.SemanticAction: Unmute the content associated with the notification.

public java.lang.CharSequencetitle

Title of the action.

Constructors
publicAction(IconCompat icon, java.lang.CharSequence title, PendingIntent intent)

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

publicAction(int icon, java.lang.CharSequence title, PendingIntent intent)

Methods
public PendingIntentgetActionIntent()

public booleangetAllowGeneratedReplies()

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

public RemoteInputgetDataOnlyRemoteInputs()

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

public BundlegetExtras()

Get additional metadata carried around with this Action.

public intgetIcon()

public IconCompatgetIconCompat()

Return the icon associated with this Action.

public RemoteInputgetRemoteInputs()

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

public intgetSemanticAction()

Returns the NotificationCompat.Action.SemanticAction associated with this NotificationCompat.Action.

public booleangetShowsUserInterface()

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

public java.lang.CharSequencegetTitle()

public booleanisAuthenticationRequired()

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

public booleanisContextual()

Returns whether this is a contextual Action, i.e.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

public static final int SEMANTIC_ACTION_NONE

NotificationCompat.Action.SemanticAction: No semantic action defined.

public static final int SEMANTIC_ACTION_REPLY

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

public static final int SEMANTIC_ACTION_MARK_AS_READ

NotificationCompat.Action.SemanticAction: Mark content as read.

public static final int SEMANTIC_ACTION_MARK_AS_UNREAD

NotificationCompat.Action.SemanticAction: Mark content as unread.

public static final int SEMANTIC_ACTION_DELETE

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

public static final int SEMANTIC_ACTION_ARCHIVE

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

public static final int SEMANTIC_ACTION_MUTE

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

public static final int SEMANTIC_ACTION_UNMUTE

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

public static final int SEMANTIC_ACTION_THUMBS_UP

NotificationCompat.Action.SemanticAction: Mark content with a thumbs up.

public static final int SEMANTIC_ACTION_THUMBS_DOWN

NotificationCompat.Action.SemanticAction: Mark content with a thumbs down.

public static final int SEMANTIC_ACTION_CALL

NotificationCompat.Action.SemanticAction: Call a contact, group, etc.

public int icon

Deprecated: Use NotificationCompat.Action.getIconCompat() instead.

Small icon representing the action.

public java.lang.CharSequence title

Title of the action.

public PendingIntent actionIntent

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

Constructors

public Action(int icon, java.lang.CharSequence title, PendingIntent intent)

public Action(IconCompat icon, java.lang.CharSequence title, PendingIntent intent)

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

Methods

public int getIcon()

Deprecated: use NotificationCompat.Action.getIconCompat() instead.

public IconCompat getIconCompat()

Return the icon associated with this Action.

public java.lang.CharSequence getTitle()

public PendingIntent getActionIntent()

public Bundle getExtras()

Get additional metadata carried around with this Action.

public boolean getAllowGeneratedReplies()

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

public boolean isAuthenticationRequired()

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.

public RemoteInput getRemoteInputs()

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 NotificationCompat.Action.getDataOnlyRemoteInputs().

public int getSemanticAction()

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

See also: NotificationCompat.Action.SemanticAction

public boolean isContextual()

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 RemoteInput getDataOnlyRemoteInputs()

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

public boolean getShowsUserInterface()

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