Action
class Action
An actionable entry that is returned as part of the android.service.credentials.BeginGetCredentialResponse, and then shown on the user selector under a separate category of 'Actions'. An action entry is expected to navigate the user to an activity belonging to the credential provider, and finally result in a androidx.credentials.GetCredentialResponse.
When selected, the associated PendingIntent is invoked to launch a provider controlled activity. The activity invoked due to this pending intent will contain the android.service.credentials.BeginGetCredentialRequest as part of the intent extras. Providers must use PendingIntentHandler.retrieveBeginGetCredentialRequest to get the request.
When the user is done interacting with the activity and the provider has a credential to return, provider must call android.app.Activity.setResult with the result code as android.app.Activity.RESULT_OK, and the android.content.Intent data that has been prepared by setting androidx.credentials.GetCredentialResponse using PendingIntentHandler.setGetCredentialResponse, or by setting androidx.credentials.exceptions.GetCredentialException using PendingIntentHandler.setGetCredentialException before ending the activity. If the provider does not have a credential, or an exception to return, provider must call android.app.Activity.setResult with the result code as android.app.Activity.RESULT_CANCELED. Setting the result code to android.app.Activity.RESULT_CANCELED will re-surface the selector.
Examples of Action entries include an entry that is titled 'Add a new Password', and navigates to the 'add password' page of the credential provider app, or an entry that is titled 'Manage Credentials' and navigates to a particular page that lists all credentials, where the user may end up selecting a credential that the provider can then return.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If |
kotlin.NullPointerException |
If |
| See also | |
|---|---|
BeginGetCredentialResponse |
for usage. |
Summary
Nested types |
|---|
class Action.BuilderA builder for |
Public companion functions |
|
|---|---|
Action? |
fromAction(action: Action)Converts a framework |
Public constructors |
|---|
Action(constructs an instance of |
Public properties |
|
|---|---|
PendingIntent |
the |
CharSequence? |
the optional subtitle that is displayed on the entry |
CharSequence |
the title of the entry |
Public companion functions
fromAction
fun fromAction(action: Action): Action?
Converts a framework android.service.credentials.Action class to a Jetpack Action class
Note that this API is not needed in a general credential retrieval flow that is implemented using this jetpack library, where you are only required to construct an instance of Action to populate the BeginGetCredentialResponse, along with setting other entries.
| Parameters | |
|---|---|
action: Action |
the instance of framework action class to be converted |
Public constructors
Action
Action(
title: CharSequence,
pendingIntent: PendingIntent,
subtitle: CharSequence? = null
)
constructs an instance of Action
| Parameters | |
|---|---|
title: CharSequence |
the title of the entry |
pendingIntent: PendingIntent |
the |
subtitle: CharSequence? = null |
the optional subtitle that is displayed on the entry |
Public functions
Public properties
pendingIntent
val pendingIntent: PendingIntent
the PendingIntent that will get invoked when the user selects this entry, must be created with a unique request code per entry, with flag PendingIntent.FLAG_MUTABLE to allow the Android system to attach the final request, and NOT with flag PendingIntent.FLAG_ONE_SHOT as it can be invoked multiple times
subtitle
val subtitle: CharSequence?
the optional subtitle that is displayed on the entry