SmsCodeRetriever

public final class SmsCodeRetriever extends Object

SmsCodeRetriever is a variant of SmsRetriever, and it provides access to Google services that help you retrieve SMS verification codes sent to the user's device, without having to ask for android.permission.READ_SMS or android.permission.RECEIVE_SMS.

To use SmsCodeRetriever, obtain an instance of SmsCodeAutofillClient using getAutofillClient(Context) or getAutofillClient(Activity), and start SMS Code Retriever service by calling startSmsCodeRetriever(). The service first looks for an SMS verification code from messages recently received (up to 1 minute prior). If there is no SMS verification code found from the SMS inbox, it waits for new incoming SMS messages until it finds an SMS verification code or reaches the timeout (about 5 minutes).

Constant Summary

String EXTRA_SMS_CODE Intent extra key of the retrieved SMS verification code as a String.
String EXTRA_STATUS Intent extra key of Status, which indicates RESULT_SUCCESS, RESULT_TIMEOUT or SmsRetrieverStatusCodes.
String SMS_CODE_RETRIEVED_ACTION Intent action when an SMS verification code is retrieved.

Public Method Summary

static SmsCodeAutofillClient
getAutofillClient(Activity activity)
Creates a new instance of SmsCodeAutofillClient for use in an Activity.
static SmsCodeAutofillClient
getAutofillClient(Context context)
Creates a new instance of SmsCodeAutofillClient for use in a Context.

Inherited Method Summary

Constants

public static final String EXTRA_SMS_CODE

Intent extra key of the retrieved SMS verification code as a String.

Constant Value: "com.google.android.gms.auth.api.phone.EXTRA_SMS_CODE"

public static final String EXTRA_STATUS

Intent extra key of Status, which indicates RESULT_SUCCESS, RESULT_TIMEOUT or SmsRetrieverStatusCodes.

Constant Value: "com.google.android.gms.auth.api.phone.EXTRA_STATUS"

public static final String SMS_CODE_RETRIEVED_ACTION

Intent action when an SMS verification code is retrieved.

Constant Value: "com.google.android.gms.auth.api.phone.SMS_CODE_RETRIEVED"

Public Methods

public static SmsCodeAutofillClient getAutofillClient (Activity activity)

Creates a new instance of SmsCodeAutofillClient for use in an Activity.

public static SmsCodeAutofillClient getAutofillClient (Context context)

Creates a new instance of SmsCodeAutofillClient for use in a Context.