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