# NotificationCompat.Action.Builder

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/app/NotificationCompat.java+class:androidx.core.app.NotificationCompat.Action.Builder) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***


```
class NotificationCompat.Action.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action.Builder#Builder(androidx.core.app.NotificationCompat.Action)(action: https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action)` Construct a new builder for `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action` object using the fields from an `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action`. |
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action.Builder#Builder(androidx.core.graphics.drawable.IconCompat,java.lang.CharSequence,android.app.PendingIntent)(icon: https://developer.android.com/reference/kotlin/androidx/core/graphics/drawable/IconCompat?, title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?, intent: https://developer.android.com/reference/android/app/PendingIntent.html?)` Construct a new builder for `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action` object. |
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action.Builder#Builder(int,java.lang.CharSequence,android.app.PendingIntent)(icon: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?, intent: https://developer.android.com/reference/android/app/PendingIntent.html?)` Construct a new builder for `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action` object. |

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

## Public constructors

### Builder

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
Builder(action: NotificationCompat.Action)
```

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

| Parameters |
|---|---|
| `action: https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action` | the action to read fields from. |

### Builder

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/core#1.2.0)

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

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

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

| Parameters |
|---|---|
| `icon: https://developer.android.com/reference/kotlin/androidx/core/graphics/drawable/IconCompat?` | icon to show for this action |
| `title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | the title of the action |
| `intent: https://developer.android.com/reference/android/app/PendingIntent.html?` | the `https://developer.android.com/reference/android/app/PendingIntent.html` to fire when users trigger this action |

### Builder

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

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

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

| Parameters |
|---|---|
| `icon: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | icon to show for this action |
| `title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | the title of the action |
| `intent: https://developer.android.com/reference/android/app/PendingIntent.html?` | the `https://developer.android.com/reference/android/app/PendingIntent.html` to fire when users trigger this action |

## Public functions

### addExtras

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
fun addExtras(extras: Bundle?): NotificationCompat.Action.Builder
```

Merge additional metadata into this builder.

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

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action#getExtras()` |   |

### addRemoteInput

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
fun addRemoteInput(remoteInput: RemoteInput?): NotificationCompat.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/androidx/core/app/RemoteInput#getResultsFromIntent(android.content.Intent)` function.

| Parameters |
|---|---|
| `remoteInput: https://developer.android.com/reference/kotlin/androidx/core/app/RemoteInput?` | a `https://developer.android.com/reference/kotlin/androidx/core/app/RemoteInput` to add to the action |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action.Builder` | this object for method chaining |

### build

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

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

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action` | the built action |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if this is a contextual Action and its Intent is null. |

### extend

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
fun extend(extender: NotificationCompat.Action.Extender): NotificationCompat.Action.Builder
```

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

### getExtras

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

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

Get the metadata Bundle used by this Builder.

The returned Bundle is shared with this Builder.

### setAllowGeneratedReplies

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

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

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

| Parameters |
|---|---|
| `allowGeneratedReplies: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` to allow generated replies, `false` otherwise |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action.Builder` | this object for method chaining The default value is `true` |

### setAuthenticationRequired

Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/core#1.8.0)

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

From API 31, sets whether the OS should only send this action's `https://developer.android.com/reference/android/app/PendingIntent.html` 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.

### setContextual

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/core#1.2.0)

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

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

### setEmphasisHint

Added in [1.19.1](https://developer.android.com/jetpack/androidx/releases/core#1.19.1)

```
fun setEmphasisHint(emphasis: Int): NotificationCompat.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/android/app/Notification.html#FLAG_PROMOTED_ONGOING` notifications, and is not binding on standard notifications.

### setSemanticAction

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
fun setSemanticAction(
    @NotificationCompat.Action.SemanticAction semanticAction: Int
): NotificationCompat.Action.Builder
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action.SemanticAction semanticAction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | a `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action.SemanticAction` defined within `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action` with `SEMANTIC_ACTION_` prefixes |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action.Builder` | this object for method chaining |

### setShowsUserInterface

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
fun setShowsUserInterface(showsUserInterface: Boolean): NotificationCompat.Action.Builder
```

Set whether or not this `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action`'s `https://developer.android.com/reference/android/app/PendingIntent.html` will open a user interface.

| Parameters |
|---|---|
| `showsUserInterface: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if this `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action`'s `https://developer.android.com/reference/android/app/PendingIntent.html` will open a user interface, otherwise `false` |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Action.Builder` | this object for method chaining The default value is `true` |

### setStyleHint

Added in [1.19.1](https://developer.android.com/jetpack/androidx/releases/core#1.19.1)

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

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