AuthenticationAction
class AuthenticationAction
An entry on the selector, denoting that the provider service is locked and authentication is needed to proceed.
Providers should set this entry when the provider app is locked, and no credentials can be returned. Providers must set the PendingIntent that leads to their unlock activity. When the user selects this entry, the corresponding PendingIntent is fired and the unlock activity is invoked.
When the user is done with the authentication flow and the provider has credential entries 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 BeginGetCredentialResponse using PendingIntentHandler.setBeginGetCredentialResponse, 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, with this authentication action labeled as having no valid credentials.
| Throws | |
|---|---|
kotlin.NullPointerException |
If the |
kotlin.IllegalArgumentException |
If the |
| See also | |
|---|---|
BeginGetCredentialResponse |
for more usage details. |
Summary
Nested types |
|---|
|
A builder for |
Public companion functions |
|
|---|---|
AuthenticationAction? |
@RequiresApi(value = 34)Converts a framework |
Public constructors |
|---|
AuthenticationAction(title: CharSequence, pendingIntent: PendingIntent)constructs an instance of |
Public properties |
|
|---|---|
PendingIntent |
the |
CharSequence |
the title to be shown with this entry on the account selector UI |
Public companion functions
fromAction
@RequiresApi(value = 34)
fun fromAction(authenticationAction: Action): AuthenticationAction?
Converts a framework android.service.credentials.Action class to a Jetpack AuthenticationAction 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 AuthenticationAction to populate the BeginGetCredentialResponse, along with setting other entries.
| Parameters | |
|---|---|
authenticationAction: Action |
the instance of framework action class to be converted |
Public constructors
AuthenticationAction
AuthenticationAction(title: CharSequence, pendingIntent: PendingIntent)
constructs an instance of AuthenticationAction
| Parameters | |
|---|---|
title: CharSequence |
the title to be shown with this entry on the account selector UI |
pendingIntent: PendingIntent |
the |
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
title
val title: CharSequence
the title to be shown with this entry on the account selector UI