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.

See also
BeginGetCredentialResponse

for usage.

Summary

Nested types

A builder for Action

Public companion functions

Action?
fromAction(action: Action)

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

Public constructors

Action(
    title: CharSequence,
    pendingIntent: PendingIntent,
    subtitle: CharSequence?
)

constructs an instance of Action

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 optional subtitle that is displayed on the entry

CharSequence

the title of the entry

Public companion functions

fromAction

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

Added in 1.2.0
Action(
    title: CharSequence,
    pendingIntent: PendingIntent,
    subtitle: CharSequence? = null
)

constructs an instance of Action

Parameters
title: CharSequence

the title of the entry

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: CharSequence? = null

the optional subtitle that is displayed on the entry

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

subtitle

Added in 1.2.0
val subtitleCharSequence?

the optional subtitle that is displayed on the entry

title

Added in 1.2.0
val titleCharSequence

the title of the entry