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

# Builder

*** ** * ** ***

```
class Builder
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.app.Notification.Action.Builder](https://developer.android.com/reference/kotlin/android/app/Notification.Action.Builder#) |

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

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/Notification.Action.Builder#Builder(android.app.Notification.Action)(action: https://developer.android.com/reference/kotlin/android/app/Notification.Action!)` Construct a new builder for `https://developer.android.com/reference/kotlin/android/app/Notification.Action` object using the fields from an `https://developer.android.com/reference/kotlin/android/app/Notification.Action`. |
| `https://developer.android.com/reference/kotlin/android/app/Notification.Action.Builder#Builder(android.graphics.drawable.Icon,%20kotlin.CharSequence,%20android.app.PendingIntent)(icon: https://developer.android.com/reference/kotlin/android/graphics/drawable/Icon.html#!, title: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html!, intent: https://developer.android.com/reference/kotlin/android/app/PendingIntent?)` Construct a new builder for `https://developer.android.com/reference/kotlin/android/app/Notification.Action` object. |
| `https://developer.android.com/reference/kotlin/android/app/Notification.Action.Builder#Builder(kotlin.Int,%20kotlin.CharSequence,%20android.app.PendingIntent)(icon: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, title: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html!, intent: https://developer.android.com/reference/kotlin/android/app/PendingIntent?)` Construct a new builder for `https://developer.android.com/reference/kotlin/android/app/Notification.Action` object. |

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

## Public constructors

### Builder

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

```
Builder(action: Notification.Action!)
```

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

| Parameters ||
|---|---|
| `action` | [Notification.Action](https://developer.android.com/reference/kotlin/android/app/Notification.Action)!: the action to read fields from |

### Builder

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

```
Builder(
    icon: Icon!, 
    title: CharSequence!, 
    intent: PendingIntent?)
```

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

As of Android `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#S:kotlin.Int`, apps targeting API level `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#S:kotlin.Int` 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/kotlin/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 android.app.Notification.Action.Style applied to the Notification.

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

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

| Parameters ||
|---|---|
| `icon` | [Icon](https://developer.android.com/reference/kotlin/android/graphics/drawable/Icon.html#)!: icon to show for this action |
| `title` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!: the title of the action |
| `intent` | [PendingIntent](https://developer.android.com/reference/kotlin/android/app/PendingIntent)?: the `https://developer.android.com/reference/kotlin/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. |

### Builder

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

```
Builder(
    icon: Int, 
    title: CharSequence!, 
    intent: PendingIntent?)
```

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

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

| Parameters ||
|---|---|
| `icon` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): icon to show for this action |
| `title` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!: the title of the action |
| `intent` | [PendingIntent](https://developer.android.com/reference/kotlin/android/app/PendingIntent)?: the `https://developer.android.com/reference/kotlin/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. |

## Public methods

### addExtras

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

```
fun addExtras(extras: Bundle!): Notification.Action.Builder
```

Merge additional metadata into this builder.

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

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/Notification.Action.Builder#` | This value cannot be `null`. |

**See Also**

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

### addRemoteInput

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

```
fun addRemoteInput(remoteInput: RemoteInput!): Notification.Action.Builder
```

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/kotlin/android/app/RemoteInput#getResultsFromIntent(android.content.Intent)` function.

| Parameters ||
|---|---|
| `remoteInput` | [RemoteInput](https://developer.android.com/reference/kotlin/android/app/RemoteInput)!: a `https://developer.android.com/reference/kotlin/android/app/RemoteInput` to add to the action |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/Notification.Action.Builder#` | this object for method chaining. This value cannot be `null`. |

### build

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

```
fun build(): Notification.Action
```

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

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/Notification.Action` | the built action. This value cannot be `null`. |

### extend

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

```
fun extend(extender: Notification.Action.Extender!): Notification.Action.Builder
```

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

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/Notification.Action.Builder#` | This value cannot be `null`. |

### getExtras

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

```
fun getExtras(): Bundle
```

Get the metadata Bundle used by this Builder.

The returned Bundle is shared with this Builder.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/os/Bundle.html#` | This value cannot be `null`. |

### setAllowGeneratedReplies

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

```
fun setAllowGeneratedReplies(allowGeneratedReplies: Boolean): Notification.Action.Builder
```

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

| Parameters ||
|---|---|
| `allowGeneratedReplies` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): `true` to allow generated replies, `false` otherwise |

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

### setAuthenticationRequired

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

```
fun setAuthenticationRequired(authenticationRequired: Boolean): Notification.Action.Builder
```

Sets whether the OS should only send this action's `https://developer.android.com/reference/kotlin/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.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/Notification.Action.Builder#` | This value cannot be `null`. |

### setContextual

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

```
fun setContextual(isContextual: Boolean): Notification.Action.Builder
```

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

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/Notification.Action.Builder#` | This value cannot be `null`. |

### setEmphasisHint

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

```
fun setEmphasisHint(emphasis: Int): Notification.Action.Builder
```

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/kotlin/android/app/Notification#FLAG_PROMOTED_ONGOING:kotlin.Int` notifications, and is not binding on standard notifications.

| Parameters ||
|---|---|
| `emphasis` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is one of the following: - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#EMPHASIS_AUTO:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#EMPHASIS_PRIMARY:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#EMPHASIS_SECONDARY:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/Notification.Action.Builder#` | This value cannot be `null`. |

### setSemanticAction

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

```
fun setSemanticAction(semanticAction: Int): Notification.Action.Builder
```

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

| Parameters ||
|---|---|
| `semanticAction` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): a SemanticAction defined within `https://developer.android.com/reference/kotlin/android/app/Notification.Action` with `SEMANTIC_ACTION_` prefixes. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#SEMANTIC_ACTION_NONE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#SEMANTIC_ACTION_REPLY:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#SEMANTIC_ACTION_MARK_AS_READ:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#SEMANTIC_ACTION_MARK_AS_UNREAD:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#SEMANTIC_ACTION_DELETE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#SEMANTIC_ACTION_ARCHIVE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#SEMANTIC_ACTION_MUTE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#SEMANTIC_ACTION_UNMUTE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#SEMANTIC_ACTION_THUMBS_UP:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#SEMANTIC_ACTION_THUMBS_DOWN:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#SEMANTIC_ACTION_CALL:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#SEMANTIC_ACTION_PLAY:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#SEMANTIC_ACTION_PAUSE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#SEMANTIC_ACTION_STOP:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/Notification.Action.Builder#` | this object for method chaining. This value cannot be `null`. |

### setStyleHint

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

```
fun setStyleHint(style: Int): Notification.Action.Builder
```

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

| Parameters ||
|---|---|
| `style` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is one of the following: - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#STYLE_AUTO:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#STYLE_TEXT_ONLY:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#STYLE_ICON_AND_TEXT:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/Notification.Action#STYLE_ICON_ONLY:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/Notification.Action.Builder#` | This value cannot be `null`. |