AuthenticationAction
public final 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 |
|---|
public final class AuthenticationAction.BuilderA builder for |
Public constructors |
|---|
AuthenticationAction(constructs an instance of |
Public methods |
|
|---|---|
boolean |
|
static final AuthenticationAction |
@RequiresApi(value = 34)Converts a framework |
final @NonNull PendingIntent |
the |
final @NonNull CharSequence |
getTitle()the title to be shown with this entry on the account selector UI |
int |
hashCode() |
Public constructors
AuthenticationAction
public AuthenticationAction(
@NonNull CharSequence title,
@NonNull PendingIntent pendingIntent
)
constructs an instance of AuthenticationAction
| Parameters | |
|---|---|
@NonNull CharSequence title |
the title to be shown with this entry on the account selector UI |
@NonNull PendingIntent pendingIntent |
the |
Public methods
fromAction
@RequiresApi(value = 34)
public static final AuthenticationAction fromAction(@NonNull 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.
getPendingIntent
public final @NonNull PendingIntent getPendingIntent()
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
getTitle
public final @NonNull CharSequence getTitle()
the title to be shown with this entry on the account selector UI