BeginGetCredentialResponse.Builder


public final class BeginGetCredentialResponse.Builder


Builder for BeginGetCredentialResponse.

Summary

Public constructors

Public methods

final @NonNull BeginGetCredentialResponse.Builder

Adds an Action to the list of actions to be displayed on the UI.

final @NonNull BeginGetCredentialResponse.Builder
addAuthenticationAction(
    @NonNull AuthenticationAction authenticationAction
)

Add an authentication entry to be shown on the UI.

final @NonNull BeginGetCredentialResponse.Builder

Adds a CredentialEntry to the list of entries to be displayed on the UI.

final @NonNull BeginGetCredentialResponse

Builds a BeginGetCredentialResponse instance.

final @NonNull BeginGetCredentialResponse.Builder

Sets the list of actions to be displayed on the UI.

final @NonNull BeginGetCredentialResponse.Builder

Sets the list of authentication entries to be displayed on the account selector UI.

final @NonNull BeginGetCredentialResponse.Builder

Sets the list of credential entries to be displayed on the account selector UI.

final @NonNull BeginGetCredentialResponse.Builder

Sets a remote credential entry to be shown on the UI.

Public constructors

Builder

Added in 1.2.0
public Builder()

Public methods

addAction

Added in 1.2.0
public final @NonNull BeginGetCredentialResponse.Builder addAction(@NonNull Action action)

Adds an Action to the list of actions to be displayed on the UI.

An [Action] must be used for independent user actions, such as opening the app, intenting directly into a certain app activity etc. The pending intent set with the [action] must invoke the corresponding activity.

addAuthenticationAction

Added in 1.2.0
public final @NonNull BeginGetCredentialResponse.Builder addAuthenticationAction(
    @NonNull AuthenticationAction authenticationAction
)

Add an authentication entry to be shown on the UI. Providers must set this entry if the corresponding account is locked and no underlying credentials can be returned.

When the user selects this [authenticationAction], the system invokes the corresponding pending intent. Once the authentication action activity is launched, and the user is authenticated, providers should create another response with [BeginGetCredentialResponse] using this time adding the unlocked credentials in the form of [CredentialEntry]'s.

The new response object must be set on the authentication activity's result. The result code should be set to [android.app.Activity#RESULT_OK] and the [CredentialProviderService#EXTRA_BEGIN_GET_CREDENTIAL_RESPONSE] extra should be set with the new fully populated [BeginGetCredentialResponse] object.

addCredentialEntry

Added in 1.2.0
public final @NonNull BeginGetCredentialResponse.Builder addCredentialEntry(@NonNull CredentialEntry entry)

Adds a CredentialEntry to the list of entries to be displayed on the UI.

build

Added in 1.2.0
public final @NonNull BeginGetCredentialResponse build()

Builds a BeginGetCredentialResponse instance.

setActions

Added in 1.2.0
public final @NonNull BeginGetCredentialResponse.Builder setActions(@NonNull List<@NonNull Action> actions)

Sets the list of actions to be displayed on the UI.

setAuthenticationActions

Added in 1.2.0
public final @NonNull BeginGetCredentialResponse.Builder setAuthenticationActions(
    @NonNull List<@NonNull AuthenticationAction> authenticationEntries
)

Sets the list of authentication entries to be displayed on the account selector UI.

setCredentialEntries

public final @NonNull BeginGetCredentialResponse.Builder setCredentialEntries(@NonNull List<@NonNull CredentialEntry> entries)

Sets the list of credential entries to be displayed on the account selector UI.

setRemoteEntry

Added in 1.2.0
public final @NonNull BeginGetCredentialResponse.Builder setRemoteEntry(RemoteEntry remoteEntry)

Sets a remote credential entry to be shown on the UI. Provider must set this if they wish to get the credential from a different device.

When constructing the CredentialEntry object, the pending intent must be set such that it leads to an activity that can provide UI to fulfill the request on a remote device. When user selects this remoteEntry, the system will invoke the pending intent set on the CredentialEntry.

Once the remote credential flow is complete, the [android.app.Activity] result should be set to [android.app.Activity#RESULT_OK] and an extra with the [CredentialProviderService#EXTRA_GET_CREDENTIAL_RESPONSE] key should be populated with a [android.credentials.Credential] object.

Note that as a provider service you will only be able to set a remote entry if : - Provider service possesses the [android.Manifest.permission.PROVIDE_REMOTE_CREDENTIALS] permission. - Provider service is configured as the provider that can provide remote entries.

If the above conditions are not met, setting back BeginGetCredentialResponse on the callback from CredentialProviderService#onBeginGetCredential will throw a SecurityException.