# 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)

*** ** * ** ***


```
public final class NotificationCompat.Action.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder#Builder(androidx.core.app.NotificationCompat.Action)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action action)` Construct a new builder for `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action` object using the fields from an `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action`. |
| `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder#Builder(androidx.core.graphics.drawable.IconCompat,java.lang.CharSequence,android.app.PendingIntent)( @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat icon, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html title, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/app/PendingIntent.html intent )` Construct a new builder for `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action` object. |
| `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder#Builder(int,java.lang.CharSequence,android.app.PendingIntent)( int icon, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html title, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/app/PendingIntent.html intent )` Construct a new builder for `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action` object. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder#addExtras(android.os.Bundle)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html extras)` Merge additional metadata into this builder. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder#addRemoteInput(androidx.core.app.RemoteInput)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/app/RemoteInput remoteInput)` Add an input to be collected from the user when this action is sent. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action` | `https://developer.android.com/reference/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/androidx/core/app/NotificationCompat.Action` object. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder#extend(androidx.core.app.NotificationCompat.Action.Extender)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Extender extender)` Apply an extender to this action builder. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder#getExtras()()` Get the metadata Bundle used by this Builder. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder#setAllowGeneratedReplies(boolean)(boolean allowGeneratedReplies)` Set whether the platform should automatically generate possible replies to add to `https://developer.android.com/reference/androidx/core/app/RemoteInput#getChoices()`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder#setAuthenticationRequired(boolean)(boolean authenticationRequired)` 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://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder#setContextual(boolean)(boolean isContextual)` Sets whether this `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action` is a contextual action, i.e. whether the action is dependent on the notification message body. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder#setEmphasisHint(int)(int emphasis)` Sets a hint about the importance of this action relative to others in this notification. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder#setSemanticAction(int)( @https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.SemanticAction int semanticAction )` Sets the `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.SemanticAction` for this `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder#setShowsUserInterface(boolean)(boolean showsUserInterface)` Set whether or not this `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action`'s `https://developer.android.com/reference/android/app/PendingIntent.html` will open a user interface. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder` | `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.Builder#setStyleHint(int)(int style)` 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)

```
public Builder(@NonNull NotificationCompat.Action action)
```

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action action` | the action to read fields from. |

### Builder

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

```
public Builder(
    @Nullable IconCompat icon,
    @Nullable CharSequence title,
    @Nullable PendingIntent intent
)
```

Construct a new builder for `https://developer.android.com/reference/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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/graphics/drawable/IconCompat icon` | icon to show for this action |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html title` | the title of the action |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/app/PendingIntent.html intent` | 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)

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

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

| Parameters |
|---|---|
| `int icon` | icon to show for this action |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html title` | the title of the action |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/app/PendingIntent.html intent` | the `https://developer.android.com/reference/android/app/PendingIntent.html` to fire when users trigger this action |

## Public methods

### addExtras

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

```
public @NonNull NotificationCompat.Action.Builder addExtras(@Nullable Bundle extras)
```

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/androidx/core/app/NotificationCompat.Action#getExtras()` |   |

### addRemoteInput

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

```
public @NonNull NotificationCompat.Action.Builder addRemoteInput(@Nullable 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/androidx/core/app/RemoteInput#getResultsFromIntent(android.content.Intent)` function.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/app/RemoteInput remoteInput` | a `https://developer.android.com/reference/androidx/core/app/RemoteInput` to add to the action |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/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)

```
public @NonNull NotificationCompat.Action build()
```

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

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/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)

```
public @NonNull NotificationCompat.Action.Builder extend(@NonNull NotificationCompat.Action.Extender extender)
```

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)

```
public @NonNull Bundle getExtras()
```

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)

```
public @NonNull NotificationCompat.Action.Builder setAllowGeneratedReplies(boolean allowGeneratedReplies)
```

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

| Parameters |
|---|---|
| `boolean allowGeneratedReplies` | `true` to allow generated replies, `false` otherwise |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/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)

```
public @NonNull NotificationCompat.Action.Builder setAuthenticationRequired(boolean authenticationRequired)
```

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)

```
public @NonNull NotificationCompat.Action.Builder setContextual(boolean isContextual)
```

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

```
public @NonNull NotificationCompat.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.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)

```
public @NonNull NotificationCompat.Action.Builder setSemanticAction(
    @NotificationCompat.Action.SemanticAction int semanticAction
)
```

Sets the `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.SemanticAction` for this `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action`. A `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.SemanticAction` denotes what an `https://developer.android.com/reference/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/androidx/core/app/NotificationCompat.Action.SemanticAction int semanticAction` | a `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.SemanticAction` defined within `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action` with `SEMANTIC_ACTION_` prefixes |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/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)

```
public @NonNull NotificationCompat.Action.Builder setShowsUserInterface(boolean showsUserInterface)
```

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

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

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/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)

```
public @NonNull NotificationCompat.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.html#FLAG_PROMOTED_ONGOING` notifications, and is not binding on standard notifications.