Builder
class Builder
kotlin.Any | |
↳ | android.app.Notification.Action.Builder |
Builder class for Action
objects.
Summary
Public constructors | |
---|---|
Builder(icon: Int, title: CharSequence!, intent: PendingIntent?) Construct a new builder for |
|
Builder(icon: Icon!, title: CharSequence!, intent: PendingIntent?) Construct a new builder for |
|
Builder(action: Notification.Action!) Construct a new builder for |
Public methods | |
---|---|
Notification.Action.Builder |
Merge additional metadata into this builder. |
Notification.Action.Builder |
addRemoteInput(remoteInput: RemoteInput!) Add an input to be collected from the user when this action is sent. |
Notification.Action |
build() Combine all of the options that have been set and return a new |
Notification.Action.Builder |
extend(extender: Notification.Action.Extender!) Apply an extender to this action builder. |
Bundle |
Get the metadata Bundle used by this Builder. |
Notification.Action.Builder |
setAllowGeneratedReplies(allowGeneratedReplies: Boolean) Set whether the platform should automatically generate possible replies to add to |
Notification.Action.Builder |
setAuthenticationRequired(authenticationRequired: Boolean) Sets whether the OS should only send this action's |
Notification.Action.Builder |
setContextual(isContextual: Boolean) Sets whether this |
Notification.Action.Builder |
setSemanticAction(semanticAction: Int) Sets the |
Public constructors
Builder
Builder(
icon: Int,
title: CharSequence!,
intent: PendingIntent?)
Construct a new builder for Action
object.
As of Android android.os.Build.VERSION_CODES#N
, action button icons will not be displayed on action buttons, but are still required and are available to notification listeners
, which may display them in other contexts, for example on a wearable device.
Parameters | |
---|---|
icon |
Int: icon to show for this action |
title |
CharSequence!: the title of the action |
intent |
PendingIntent?: the 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
Builder(
icon: Icon!,
title: CharSequence!,
intent: PendingIntent?)
Construct a new builder for Action
object.
As of Android android.os.Build.VERSION_CODES#S
, apps targeting API level android.os.Build.VERSION_CODES#S
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 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 Style
applied to the Notification.
As of Android android.os.Build.VERSION_CODES#N
, action button icons will not be displayed on action buttons, but are still required and are available to notification
, which may display them in other contexts, for example on a wearable device.
When the title
is a android.text.Spanned
, any colors set by a ForegroundColorSpan
or TextAppearanceSpan
may be removed or displayed with an altered in luminance to ensure proper contrast within the Notification.
Parameters | |
---|---|
icon |
Icon!: icon to show for this action |
title |
CharSequence!: the title of the action |
intent |
PendingIntent?: the 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
Builder(action: Notification.Action!)
Construct a new builder for Action
object using the fields from an Action
.
Parameters | |
---|---|
action |
Notification.Action!: the action to read fields from. |
Public methods
addExtras
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 | |
---|---|
Notification.Action.Builder |
This value cannot be null . |
addRemoteInput
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 RemoteInput#getResultsFromIntent
function.
Parameters | |
---|---|
remoteInput |
RemoteInput!: a RemoteInput to add to the action |
Return | |
---|---|
Notification.Action.Builder |
this object for method chaining This value cannot be null . |
build
fun build(): Notification.Action
Combine all of the options that have been set and return a new Action
object.
Return | |
---|---|
Notification.Action |
the built action This value cannot be null . |
extend
fun extend(extender: Notification.Action.Extender!): Notification.Action.Builder
Apply an extender to this action builder. Extenders may be used to add metadata or change options on this builder.
Return | |
---|---|
Notification.Action.Builder |
This value cannot be null . |
getExtras
fun getExtras(): Bundle
Get the metadata Bundle used by this Builder.
The returned Bundle is shared with this Builder.
Return | |
---|---|
Bundle |
This value cannot be null . |
setAllowGeneratedReplies
fun setAllowGeneratedReplies(allowGeneratedReplies: Boolean): Notification.Action.Builder
Set whether the platform should automatically generate possible replies to add to RemoteInput#getChoices()
. If the Action
doesn't have a RemoteInput
, this has no effect.
Parameters | |
---|---|
allowGeneratedReplies |
Boolean: true to allow generated replies, false otherwise |
Return | |
---|---|
Notification.Action.Builder |
this object for method chaining The default value is true This value cannot be null . |
setAuthenticationRequired
fun setAuthenticationRequired(authenticationRequired: Boolean): Notification.Action.Builder
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.
Return | |
---|---|
Notification.Action.Builder |
This value cannot be null . |
setContextual
fun setContextual(isContextual: Boolean): Notification.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.
Return | |
---|---|
Notification.Action.Builder |
This value cannot be null . |
setSemanticAction
fun setSemanticAction(semanticAction: Int): Notification.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 | |
---|---|
semanticAction |
Int: a SemanticAction defined within Action with SEMANTIC_ACTION_ prefixes Value is android.app.Notification.Action#SEMANTIC_ACTION_NONE , android.app.Notification.Action#SEMANTIC_ACTION_REPLY , android.app.Notification.Action#SEMANTIC_ACTION_MARK_AS_READ , android.app.Notification.Action#SEMANTIC_ACTION_MARK_AS_UNREAD , android.app.Notification.Action#SEMANTIC_ACTION_DELETE , android.app.Notification.Action#SEMANTIC_ACTION_ARCHIVE , android.app.Notification.Action#SEMANTIC_ACTION_MUTE , android.app.Notification.Action#SEMANTIC_ACTION_UNMUTE , android.app.Notification.Action#SEMANTIC_ACTION_THUMBS_UP , android.app.Notification.Action#SEMANTIC_ACTION_THUMBS_DOWN , android.app.Notification.Action#SEMANTIC_ACTION_CALL , android.app.Notification.Action.SEMANTIC_ACTION_MARK_CONVERSATION_AS_PRIORITY, or android.app.Notification.Action.SEMANTIC_ACTION_CONVERSATION_IS_PHISHING |
Return | |
---|---|
Notification.Action.Builder |
this object for method chaining This value cannot be null . |