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.

See also
BeginGetCredentialResponse

for more usage details.

Summary

Nested types

A builder for AuthenticationAction

Public companion functions

AuthenticationAction?
@RequiresApi(value = 34)
fromAction(authenticationAction: Action)

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

Public constructors

constructs an instance of AuthenticationAction

Public functions

open operator Boolean
equals(other: Any?)
open Int

Public properties

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

CharSequence

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

Public companion functions

fromAction

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

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

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

Public properties

pendingIntent

Added in 1.2.0
val pendingIntentPendingIntent

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

Added in 1.2.0
val titleCharSequence

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