Added in [API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/app/Notification.Action.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/app/Notification.Action.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/Notification.Action.Builder#inhmethods)

# Notification.Action.Builder

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/app/Notification.Action.Builder "View this page in Kotlin") \|Java


`
public
static
final

class
Notification.Action.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.Notification.Action.Builder |

<br />

*** ** * ** ***

Builder class for `https://developer.android.com/reference/android/app/Notification.Action` objects.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/app/Notification.Action.Builder#Builder(android.app.Notification.Action)(https://developer.android.com/reference/android/app/Notification.Action action) ` Construct a new builder for `https://developer.android.com/reference/android/app/Notification.Action` object using the fields from an `https://developer.android.com/reference/android/app/Notification.Action`. |
| ` https://developer.android.com/reference/android/app/Notification.Action.Builder#Builder(android.graphics.drawable.Icon,%20java.lang.CharSequence,%20android.app.PendingIntent)(https://developer.android.com/reference/android/graphics/drawable/Icon icon, https://developer.android.com/reference/java/lang/CharSequence title, https://developer.android.com/reference/android/app/PendingIntent intent) ` Construct a new builder for `https://developer.android.com/reference/android/app/Notification.Action` object. |
| ` https://developer.android.com/reference/android/app/Notification.Action.Builder#Builder(int,%20java.lang.CharSequence,%20android.app.PendingIntent)(int icon, https://developer.android.com/reference/java/lang/CharSequence title, https://developer.android.com/reference/android/app/PendingIntent intent) ` Construct a new builder for `https://developer.android.com/reference/android/app/Notification.Action` object. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/app/Notification.Action.Builder` | ` https://developer.android.com/reference/android/app/Notification.Action.Builder#addExtras(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle extras) ` Merge additional metadata into this builder. |
| ` https://developer.android.com/reference/android/app/Notification.Action.Builder` | ` https://developer.android.com/reference/android/app/Notification.Action.Builder#addRemoteInput(android.app.RemoteInput)(https://developer.android.com/reference/android/app/RemoteInput remoteInput) ` Add an input to be collected from the user when this action is sent. |
| ` https://developer.android.com/reference/android/app/Notification.Action` | ` https://developer.android.com/reference/android/app/Notification.Action.Builder#build()() ` Combine all of the options that have been set and return a new `https://developer.android.com/reference/android/app/Notification.Action` object. |
| ` https://developer.android.com/reference/android/app/Notification.Action.Builder` | ` https://developer.android.com/reference/android/app/Notification.Action.Builder#extend(android.app.Notification.Action.Extender)(https://developer.android.com/reference/android/app/Notification.Action.Extender extender) ` Apply an `https://developer.android.com/reference/android/app/Notification.Action.Extender` to this action builder. |
| ` https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/app/Notification.Action.Builder#getExtras()() ` Get the metadata Bundle used by this Builder. |
| ` https://developer.android.com/reference/android/app/Notification.Action.Builder` | ` https://developer.android.com/reference/android/app/Notification.Action.Builder#setAllowGeneratedReplies(boolean)(boolean allowGeneratedReplies) ` Set whether the platform should automatically generate possible replies to add to `https://developer.android.com/reference/android/app/RemoteInput#getChoices()`. |
| ` https://developer.android.com/reference/android/app/Notification.Action.Builder` | ` https://developer.android.com/reference/android/app/Notification.Action.Builder#setAuthenticationRequired(boolean)(boolean authenticationRequired) ` Sets whether the OS should only send this action's `https://developer.android.com/reference/android/app/PendingIntent` on an unlocked device. |
| ` https://developer.android.com/reference/android/app/Notification.Action.Builder` | ` https://developer.android.com/reference/android/app/Notification.Action.Builder#setContextual(boolean)(boolean isContextual) ` Sets whether this `https://developer.android.com/reference/android/app/Notification.Action` is a contextual action, i.e. |
| ` https://developer.android.com/reference/android/app/Notification.Action.Builder` | ` https://developer.android.com/reference/android/app/Notification.Action.Builder#setEmphasisHint(int)(int emphasis) ` Sets a hint about the importance of this action relative to others in this notification. |
| ` https://developer.android.com/reference/android/app/Notification.Action.Builder` | ` https://developer.android.com/reference/android/app/Notification.Action.Builder#setSemanticAction(int)(int semanticAction) ` Sets the `SemanticAction` for this `https://developer.android.com/reference/android/app/Notification.Action`. |
| ` https://developer.android.com/reference/android/app/Notification.Action.Builder` | ` https://developer.android.com/reference/android/app/Notification.Action.Builder#setStyleHint(int)(int style) ` Sets a preferred visual style of this action. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### Builder

Added in [API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder (Notification.Action action)
```

Construct a new builder for `https://developer.android.com/reference/android/app/Notification.Action` object using the fields from an
`https://developer.android.com/reference/android/app/Notification.Action`.

<br />

| Parameters ||
|---|---|
| `action` | `Notification.Action`: the action to read fields from <br /> |

### Builder

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

Construct a new builder for `https://developer.android.com/reference/android/app/Notification.Action` object.

As of Android `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S`, apps targeting API level
`https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or higher won't be able to start activities
while processing broadcast receivers or services in response to notification action
clicks. To launch an activity in those cases, provide a `https://developer.android.com/reference/android/app/PendingIntent` for the
activity itself.

How an Action is displayed, including whether the `icon`, `text`, or
both are displayed or required, depends on where and how the action is used, and the
`https://developer.android.com/` applied to the Notification.

As of Android `https://developer.android.com/reference/android/os/Build.VERSION_CODES#N`, action button icons
will not be displayed on action buttons, but are still required and are available
to `https://developer.android.com/reference/android/service/notification/NotificationListenerService`, which may display them in other contexts, for example on a wearable
device.

When the `title` is a `https://developer.android.com/reference/android/text/Spanned`, any colors set by a
`https://developer.android.com/reference/android/text/style/ForegroundColorSpan` or `https://developer.android.com/reference/android/text/style/TextAppearanceSpan` may be removed or displayed
with an altered in luminance to ensure proper contrast within the Notification.

<br />

| Parameters ||
|---|---|
| `icon` | `Icon`: icon to show for this action <br /> |
| `title` | `CharSequence`: the title of the action <br /> |
| `intent` | `PendingIntent`: the `https://developer.android.com/reference/android/app/PendingIntent` to fire when users trigger this action. May be null, in which case the action may be rendered in a disabled presentation by the system UI. <br /> |

### Builder

Added in [API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

Construct a new builder for `https://developer.android.com/reference/android/app/Notification.Action` object.

As of Android `https://developer.android.com/reference/android/os/Build.VERSION_CODES#N`,
action button icons will not be displayed on action buttons, but are still required
and are available to
`https://developer.android.com/reference/android/service/notification/NotificationListenerService`,
which may display them in other contexts, for example on a wearable device.

<br />

| Parameters ||
|---|---|
| `icon` | `int`: icon to show for this action <br /> |
| `title` | `CharSequence`: the title of the action <br /> |
| `intent` | `PendingIntent`: the `https://developer.android.com/reference/android/app/PendingIntent` to fire when users trigger this action. May be null, in which case the action may be rendered in a disabled presentation by the system UI. <br /> |

## Public methods

### addExtras

Added in [API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

| Parameters ||
|---|---|
| `extras` | `Bundle` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.Action.Builder` | This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/Notification#extras`

### addRemoteInput

Added in [API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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
`https://developer.android.com/reference/android/app/RemoteInput#getResultsFromIntent(android.content.Intent)` function.

<br />

| Parameters ||
|---|---|
| `remoteInput` | `RemoteInput`: a `https://developer.android.com/reference/android/app/RemoteInput` to add to the action <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.Action.Builder` | this object for method chaining. This value cannot be `null`. <br /> |

### build

Added in [API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Notification.Action build ()
```

Combine all of the options that have been set and return a new `https://developer.android.com/reference/android/app/Notification.Action`
object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.Action` | the built action. This value cannot be `null`. <br /> |

### extend

Added in [API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

Apply an `https://developer.android.com/reference/android/app/Notification.Action.Extender` to this action builder. Extenders may be used to add
metadata or change options on this builder.

<br />

| Parameters ||
|---|---|
| `extender` | `Notification.Action.Extender` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.Action.Builder` | This value cannot be `null`. <br /> |

### getExtras

Added in [API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Bundle getExtras ()
```

Get the metadata Bundle used by this Builder.

The returned Bundle is shared with this Builder.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | This value cannot be `null`. <br /> |

### setAllowGeneratedReplies

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Notification.Action.Builder setAllowGeneratedReplies (boolean allowGeneratedReplies)
```

Set whether the platform should automatically generate possible replies to add to
`https://developer.android.com/reference/android/app/RemoteInput#getChoices()`. If the `https://developer.android.com/reference/android/app/Notification.Action` doesn't have a
`https://developer.android.com/reference/android/app/RemoteInput`, this has no effect.

<br />

| Parameters ||
|---|---|
| `allowGeneratedReplies` | `boolean`: `true` to allow generated replies, `false` otherwise <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.Action.Builder` | this object for method chaining The default value is `true` This value cannot be `null`. <br /> |

### setAuthenticationRequired

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Notification.Action.Builder setAuthenticationRequired (boolean authenticationRequired)
```

Sets whether the OS should only send this action's `https://developer.android.com/reference/android/app/PendingIntent` on an
unlocked device.

If this is `true` and the device is locked when the action is invoked, the
OS will show the keyguard and require successful authentication before invoking the
intent. If this is `false` and the device is locked, the OS will decide whether
authentication should be required.

<br />

| Parameters ||
|---|---|
| `authenticationRequired` | `boolean` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.Action.Builder` | This value cannot be `null`. <br /> |

### setContextual

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Notification.Action.Builder setContextual (boolean isContextual)
```

Sets whether this `https://developer.android.com/reference/android/app/Notification.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.

<br />

| Parameters ||
|---|---|
| `isContextual` | `boolean` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.Action.Builder` | This value cannot be `null`. <br /> |

### setEmphasisHint

Added in [API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Notification.Action.Builder setEmphasisHint (int emphasis)
```

Sets a hint about the importance of this action relative to others in this
notification. This may be used for `https://developer.android.com/reference/android/app/Notification#FLAG_PROMOTED_ONGOING` notifications, and is not binding on standard notifications.

<br />

| Parameters ||
|---|---|
| `emphasis` | `int`: Value is one of the following: - `https://developer.android.com/reference/android/app/Notification.Action#EMPHASIS_AUTO` - `https://developer.android.com/reference/android/app/Notification.Action#EMPHASIS_PRIMARY` - `https://developer.android.com/reference/android/app/Notification.Action#EMPHASIS_SECONDARY` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.Action.Builder` | This value cannot be `null`. <br /> |

### setSemanticAction

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Notification.Action.Builder setSemanticAction (int semanticAction)
```

Sets the `SemanticAction` for this `https://developer.android.com/reference/android/app/Notification.Action`. A
`SemanticAction` denotes what an `https://developer.android.com/reference/android/app/Notification.Action`'s
`https://developer.android.com/reference/android/app/PendingIntent` will do (eg. reply, mark as read, delete, etc).

<br />

| Parameters ||
|---|---|
| `semanticAction` | `int`: a SemanticAction defined within `https://developer.android.com/reference/android/app/Notification.Action` with `SEMANTIC_ACTION_` prefixes. Value is one of the following: - `https://developer.android.com/reference/android/app/Notification.Action#SEMANTIC_ACTION_NONE` - `https://developer.android.com/reference/android/app/Notification.Action#SEMANTIC_ACTION_REPLY` - `https://developer.android.com/reference/android/app/Notification.Action#SEMANTIC_ACTION_MARK_AS_READ` - `https://developer.android.com/reference/android/app/Notification.Action#SEMANTIC_ACTION_MARK_AS_UNREAD` - `https://developer.android.com/reference/android/app/Notification.Action#SEMANTIC_ACTION_DELETE` - `https://developer.android.com/reference/android/app/Notification.Action#SEMANTIC_ACTION_ARCHIVE` - `https://developer.android.com/reference/android/app/Notification.Action#SEMANTIC_ACTION_MUTE` - `https://developer.android.com/reference/android/app/Notification.Action#SEMANTIC_ACTION_UNMUTE` - `https://developer.android.com/reference/android/app/Notification.Action#SEMANTIC_ACTION_THUMBS_UP` - `https://developer.android.com/reference/android/app/Notification.Action#SEMANTIC_ACTION_THUMBS_DOWN` - `https://developer.android.com/reference/android/app/Notification.Action#SEMANTIC_ACTION_CALL` - `https://developer.android.com/reference/android/app/Notification.Action#SEMANTIC_ACTION_PLAY` - `https://developer.android.com/reference/android/app/Notification.Action#SEMANTIC_ACTION_PAUSE` - `https://developer.android.com/reference/android/app/Notification.Action#SEMANTIC_ACTION_STOP` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.Action.Builder` | this object for method chaining. This value cannot be `null`. <br /> |

### setStyleHint

Added in [API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Notification.Action.Builder setStyleHint (int style)
```

Sets a preferred visual style of this action. This may be used for
`https://developer.android.com/reference/android/app/Notification#FLAG_PROMOTED_ONGOING` notifications, and is
not binding on standard notifications.

<br />

| Parameters ||
|---|---|
| `style` | `int`: Value is one of the following: - `https://developer.android.com/reference/android/app/Notification.Action#STYLE_AUTO` - `https://developer.android.com/reference/android/app/Notification.Action#STYLE_TEXT_ONLY` - `https://developer.android.com/reference/android/app/Notification.Action#STYLE_ICON_AND_TEXT` - `https://developer.android.com/reference/android/app/Notification.Action#STYLE_ICON_ONLY` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.Action.Builder` | This value cannot be `null`. <br /> |