IntentHelper

object IntentHelper


Helpers for composing / retrieving the activity result data.

Summary

Constants

const 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.

const String

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

Public functions

CallingAppInfo?

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

GetCredentialRequest?

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

GetCredentialResponse
extractGetCredentialResponse(resultCode: Int, resultData: Bundle)

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

Unit
setGetCredentialException(
    intent: Intent,
    errorType: String,
    errorMessage: String?
)

Sets the exception to be returned to the activity launcher.

Unit

Sets the Credential to be returned to the activity launcher.

Constants

ACTION_GET_CREDENTIAL

const val ACTION_GET_CREDENTIALString

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

const val EXTRA_CREDENTIAL_IDString

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

Public functions

extractCallingAppInfo

fun extractCallingAppInfo(intent: Intent): CallingAppInfo?

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

Parameters
intent: Intent

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

extractGetCredentialRequest

fun extractGetCredentialRequest(intent: Intent): GetCredentialRequest?

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

Parameters
intent: Intent

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

extractGetCredentialResponse

fun extractGetCredentialResponse(resultCode: Int, resultData: Bundle): GetCredentialResponse

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

Parameters
resultCode: Int

the resultCode returned by the getCredential PendingIntent launching

resultData: Bundle

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

fun setGetCredentialException(
    intent: Intent,
    errorType: String,
    errorMessage: String?
): Unit

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
intent: Intent

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

errorType: String

the type of the error that occurred during the operation

errorMessage: String?

the debugging message of the error that occurred during the operation

setGetCredentialResponse

fun setGetCredentialResponse(intent: Intent, response: GetCredentialResponse): Unit

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
intent: Intent

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

response: GetCredentialResponse

the GetCredentialResponse to set as the result data