# Print output for @column tags ?> Notification.Action.Builder - Android SDK | Android Developers

Most visited

Recently visited

Notification.Action.Builder

public static final class Notification.Action.Builder
extends Object

java.lang.Object
   ↳ android.app.Notification.Action.Builder


Builder class for Action objects.

Summary

Public constructors

Builder(int icon, CharSequence title, PendingIntent intent)

Construct a new builder for Action object.

Builder(Icon icon, CharSequence title, PendingIntent intent)

Construct a new builder for Action object.

Builder(Notification.Action action)

Construct a new builder for Action object using the fields from an Action.

Public methods

Notification.Action.Builder addExtras(Bundle extras)

Merge additional metadata into this builder.

Notification.Action.Builder addRemoteInput(RemoteInput remoteInput)

Add an input to be collected from the user when this action is sent.

Notification.Action build()

Combine all of the options that have been set and return a new Action object.

Notification.Action.Builder extend(Notification.Action.Extender extender)

Apply an extender to this action builder.

Bundle getExtras()

Get the metadata Bundle used by this Builder.

Notification.Action.Builder setAllowGeneratedReplies(boolean allowGeneratedReplies)

Set whether the platform should automatically generate possible replies to add to RemoteInput#getChoices().

Notification.Action.Builder setContextual(boolean isContextual)

Sets whether this Action is a contextual action, i.e.

Notification.Action.Builder setSemanticAction(int semanticAction)

Sets the SemanticAction for this Action.

Inherited methods

Public constructors

Builder

public Builder (int icon, 
                CharSequence title, 
                PendingIntent intent)

Construct a new builder for Action object.

Parameters
icon int: icon to show for this action

title CharSequence: the title of the action

intent PendingIntent: the PendingIntent to fire when users trigger this action

Builder

public Builder (Icon icon, 
                CharSequence title, 
                PendingIntent intent)

Construct a new builder for Action object.

Parameters
icon Icon: icon to show for this action

title CharSequence: the title of the action

intent PendingIntent: the PendingIntent to fire when users trigger this action

Builder

public Builder (Notification.Action action)

Construct a new builder for Action object using the fields from an Action.

Parameters
action Notification.Action: the action to read fields from.

Public methods

addExtras

public Notification.Action.Builder addExtras (Bundle extras)

Merge additional metadata into this builder.

Values within the Bundle will replace existing extras values in this Builder.

Parameters
extras Bundle

Returns
Notification.Action.Builder This value cannot be null.

See also:

addRemoteInput

public Notification.Action.Builder addRemoteInput (RemoteInput remoteInput)

Add an input to be collected from the user when this action is sent. Response values can be retrieved from the fired intent by using the RemoteInput#getResultsFromIntent function.

Parameters
remoteInput RemoteInput: a RemoteInput to add to the action

Returns
Notification.Action.Builder this object for method chaining This value cannot be null.

build

public Notification.Action build ()

Combine all of the options that have been set and return a new Action object.

Returns
Notification.Action the built action This value cannot be null.

extend

public Notification.Action.Builder extend (Notification.Action.Extender extender)

Apply an extender to this action builder. Extenders may be used to add metadata or change options on this builder.

Parameters
extender Notification.Action.Extender

Returns
Notification.Action.Builder This value cannot be null.

getExtras

public Bundle getExtras ()

Get the metadata Bundle used by this Builder.

The returned Bundle is shared with this Builder.

Returns
Bundle This value cannot be null.

setAllowGeneratedReplies

public Notification.Action.Builder setAllowGeneratedReplies (boolean allowGeneratedReplies)

Set whether the platform should automatically generate possible replies to add to RemoteInput#getChoices(). If the Action doesn't have a RemoteInput, this has no effect.

Parameters
allowGeneratedReplies boolean: true to allow generated replies, false otherwise

Returns
Notification.Action.Builder this object for method chaining The default value is true This value cannot be null.

setContextual

public Notification.Action.Builder setContextual (boolean isContextual)

Sets whether this Action 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.

Parameters
isContextual boolean

Returns
Notification.Action.Builder This value cannot be null.

setSemanticAction

public Notification.Action.Builder setSemanticAction (int semanticAction)

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

Parameters
semanticAction int: a SemanticAction defined within Action with SEMANTIC_ACTION_ prefixes Value is Notification.Action.SEMANTIC_ACTION_NONE, Notification.Action.SEMANTIC_ACTION_REPLY, Notification.Action.SEMANTIC_ACTION_MARK_AS_READ, Notification.Action.SEMANTIC_ACTION_MARK_AS_UNREAD, Notification.Action.SEMANTIC_ACTION_DELETE, Notification.Action.SEMANTIC_ACTION_ARCHIVE, Notification.Action.SEMANTIC_ACTION_MUTE, Notification.Action.SEMANTIC_ACTION_UNMUTE, Notification.Action.SEMANTIC_ACTION_THUMBS_UP, Notification.Action.SEMANTIC_ACTION_THUMBS_DOWN, or Notification.Action.SEMANTIC_ACTION_CALL

Returns
Notification.Action.Builder this object for method chaining This value cannot be null.