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.

See also
BeginGetCredentialResponse

for more usage details.

Summary

Nested types

public final class AuthenticationAction.Builder

A builder for AuthenticationAction

Public constructors

AuthenticationAction(
    @NonNull CharSequence title,
    @NonNull PendingIntent pendingIntent
)

constructs an instance of AuthenticationAction

Public methods

boolean
equals(Object other)
static final AuthenticationAction
@RequiresApi(value = 34)
fromAction(@NonNull Action authenticationAction)

Converts a framework android.service.credentials.Action class to a Jetpack AuthenticationAction class

final @NonNull 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

final @NonNull CharSequence

the title to be shown with this entry on the account selector UI

int

Public constructors

AuthenticationAction

Added in 1.2.0
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 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

Public methods

equals

public boolean equals(Object other)

fromAction

Added in 1.5.0-beta01
@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.

Parameters
@NonNull Action authenticationAction

the instance of framework action class to be converted

getPendingIntent

Added in 1.2.0
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

Added in 1.2.0
public final @NonNull CharSequence getTitle()

the title to be shown with this entry on the account selector UI

hashCode

public int hashCode()