NotificationCompat.Action.Builder
public final class NotificationCompat.Action.Builder
Builder class for Action objects.
Summary
Public constructors |
|---|
Builder(@NonNull NotificationCompat.Action action)Construct a new builder for |
Builder(Construct a new builder for |
Builder(Construct a new builder for |
Public methods |
|
|---|---|
@NonNull NotificationCompat.Action.Builder |
Merge additional metadata into this builder. |
@NonNull NotificationCompat.Action.Builder |
addRemoteInput(@Nullable RemoteInput remoteInput)Add an input to be collected from the user when this action is sent. |
@NonNull NotificationCompat.Action |
build()Combine all of the options that have been set and return a new |
@NonNull NotificationCompat.Action.Builder |
extend(@NonNull NotificationCompat.Action.Extender extender)Apply an extender to this action builder. |
@NonNull Bundle |
Get the metadata Bundle used by this Builder. |
@NonNull NotificationCompat.Action.Builder |
setAllowGeneratedReplies(boolean allowGeneratedReplies)Set whether the platform should automatically generate possible replies to add to |
@NonNull NotificationCompat.Action.Builder |
setAuthenticationRequired(boolean authenticationRequired)From API 31, sets whether the OS should only send this action's |
@NonNull NotificationCompat.Action.Builder |
setContextual(boolean isContextual)Sets whether this |
@NonNull NotificationCompat.Action.Builder |
setSemanticAction(Sets the |
@NonNull NotificationCompat.Action.Builder |
setShowsUserInterface(boolean showsUserInterface)Set whether or not this |
Public constructors
Builder
public Builder(@NonNull NotificationCompat.Action action)
Construct a new builder for Action object using the fields from an Action.
| Parameters | |
|---|---|
@NonNull NotificationCompat.Action action |
the action to read fields from. |
Builder
public Builder(
@Nullable IconCompat icon,
@Nullable CharSequence title,
@Nullable PendingIntent intent
)
Construct a new builder for 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 | |
|---|---|
@Nullable IconCompat icon |
icon to show for this action |
@Nullable CharSequence title |
the title of the action |
@Nullable PendingIntent intent |
the |
Builder
public Builder(
int icon,
@Nullable CharSequence title,
@Nullable PendingIntent intent
)
Construct a new builder for Action object.
| Parameters | |
|---|---|
int icon |
icon to show for this action |
@Nullable CharSequence title |
the title of the action |
@Nullable PendingIntent intent |
the |
Public methods
addExtras
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 | |
|---|---|
getExtras |
addRemoteInput
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 getResultsFromIntent function.
| Parameters | |
|---|---|
@Nullable RemoteInput remoteInput |
a |
| Returns | |
|---|---|
@NonNull NotificationCompat.Action.Builder |
this object for method chaining |
build
public @NonNull NotificationCompat.Action build()
Combine all of the options that have been set and return a new Action object.
| Returns | |
|---|---|
@NonNull NotificationCompat.Action |
the built action |
| Throws | |
|---|---|
java.lang.NullPointerException |
if this is a contextual Action and its Intent is null. |
extend
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
public @NonNull Bundle getExtras()
Get the metadata Bundle used by this Builder.
The returned Bundle is shared with this Builder.
setAllowGeneratedReplies
public @NonNull NotificationCompat.Action.Builder setAllowGeneratedReplies(boolean allowGeneratedReplies)
Set whether the platform should automatically generate possible replies to add to getChoices. If the Action doesn't have a RemoteInput, this has no effect.
| Parameters | |
|---|---|
boolean allowGeneratedReplies |
|
| Returns | |
|---|---|
@NonNull NotificationCompat.Action.Builder |
this object for method chaining The default value is |
setAuthenticationRequired
public @NonNull NotificationCompat.Action.Builder setAuthenticationRequired(boolean authenticationRequired)
From API 31, sets whether the OS should only send this action's 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.
setContextual
public @NonNull NotificationCompat.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.
setSemanticAction
public @NonNull NotificationCompat.Action.Builder setSemanticAction(
@NotificationCompat.Action.SemanticAction 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 | |
|---|---|
@NotificationCompat.Action.SemanticAction int semanticAction |
a |
| Returns | |
|---|---|
@NonNull NotificationCompat.Action.Builder |
this object for method chaining |
setShowsUserInterface
public @NonNull NotificationCompat.Action.Builder setShowsUserInterface(boolean showsUserInterface)
Set whether or not this Action's PendingIntent will open a user interface.
| Parameters | |
|---|---|
boolean showsUserInterface |
|
| Returns | |
|---|---|
@NonNull NotificationCompat.Action.Builder |
this object for method chaining The default value is |