IntentHelper

public static class IntentHelper


Helpers for composing / retrieving the activity result data.

Summary

Constants

static final @NonNull String

Intent action declared by a provider activity to complete a get-credential request when one one of its provided options is selected by the user.

static final @NonNull String

Intent extra key for the id of the credential that was selected by the user.

Public fields

static @NonNull IntentHelper

Public methods

static final CallingAppInfo

Allows a provider to extract the calling app information from the system ui launching intent.

static final GetCredentialRequest

Allows a provider to extract the calling request from the system ui launching intent.

static final @NonNull GetCredentialResponse
extractGetCredentialResponse(int resultCode, @NonNull Bundle resultData)

Extracts the Credential from the given activity result Intent data if it is present.

static final void
setGetCredentialException(
    @NonNull Intent intent,
    @NonNull String errorType,
    String errorMessage
)

Sets the exception to be returned to the activity launcher.

static final void

Sets the Credential to be returned to the activity launcher.

Constants

ACTION_GET_CREDENTIAL

public static final @NonNull String ACTION_GET_CREDENTIAL

Intent action declared by a provider activity to complete a get-credential request when one one of its provided options is selected by the user.

EXTRA_CREDENTIAL_ID

public static final @NonNull String EXTRA_CREDENTIAL_ID

Intent extra key for the id of the credential that was selected by the user.

Public fields

INSTANCE

public static @NonNull IntentHelper INSTANCE

Public methods

extractCallingAppInfo

public static final CallingAppInfo extractCallingAppInfo(@NonNull Intent intent)

Allows a provider to extract the calling app information from the system ui launching intent.

Parameters
@NonNull Intent intent

the intent from which to extract the CallingAppInfo; this should be the intent that was used to launch your provider activity

extractGetCredentialRequest

public static final GetCredentialRequest extractGetCredentialRequest(@NonNull Intent intent)

Allows a provider to extract the calling request from the system ui launching intent.

Parameters
@NonNull Intent intent

the intent from which to extract the GetCredentialRequest; this should be the intent that was used to launch your provider activity

extractGetCredentialResponse

public static final @NonNull GetCredentialResponse extractGetCredentialResponse(int resultCode, @NonNull Bundle resultData)

Extracts the Credential from the given activity result Intent data if it is present.

Parameters
int resultCode

the resultCode returned by the getCredential PendingIntent launching

@NonNull Bundle resultData

the extras of the resultData returned by the getCredential PendingIntent launching

Throws
com.google.android.gms.identitycredentials.GetCredentialException

if the given operation has failed.

setGetCredentialException

public static final void setGetCredentialException(
    @NonNull Intent intent,
    @NonNull String errorType,
    String errorMessage
)

Sets the exception to be returned to the activity launcher.

A credential provider must set the result code to Activity.RESULT_OK if a valid credential, or a valid exception is being set as the data to the result. However, if the credential provider is unable to resolve to a valid response or exception, the result code must be set to Activity.RESULT_CANCELED. Note that setting the result code to Activity.RESULT_CANCELED will re-surface the account selection bottom sheet that displayed the original credential options, hence allowing the user to re-select.

Parameters
@NonNull Intent intent

the intent to which to set error; this should be the intent data that you use in the Activity.setResult call

@NonNull String errorType

the type of the error that occurred during the operation

String errorMessage

the debugging message of the error that occurred during the operation

setGetCredentialResponse

public static final void setGetCredentialResponse(
    @NonNull Intent intent,
    @NonNull GetCredentialResponse response
)

Sets the Credential to be returned to the activity launcher.

A credential provider must set the result code to Activity.RESULT_OK if a valid credential, or a valid exception is being set as the data to the result. However, if the credential provider is unable to resolve to a valid response or exception, the result code must be set to Activity.RESULT_CANCELED. Note that setting the result code to Activity.RESULT_CANCELED will re-surface the account selection bottom sheet that displayed the original credential options, hence allowing the user to re-select.

Parameters
@NonNull Intent intent

the intent to which to set the response; this should be the intent data that you use in the Activity.setResult call

@NonNull GetCredentialResponse response

the GetCredentialResponse to set as the result data