SmsRetriever

public final class SmsRetriever extends Object

SmsRetriever provides access to Google services that help you retrieve SMS messages sent to your app without having to ask for android.permission.READ_SMS or android.permission.RECEIVE_SMS.

To use SmsRetriever, obtain an instance of SmsRetrieverClient using getClient(Context) or getClient(Activity), then start the SMS retriever service by calling startSmsRetriever() or startSmsUserConsent(String). The service waits for a matching SMS message until timeout (5 minutes).

Constant Summary

String EXTRA_CONSENT_INTENT Intent extra key of the consent intent to be launched from client app.
String EXTRA_SIM_SUBSCRIPTION_ID [Optional] Intent extra key of the retrieved Sim card subscription Id if any, as an int.
String EXTRA_SMS_MESSAGE Intent extra key of the retrieved SMS message as a String.
String EXTRA_STATUS Intent extra key of Status, which indicates SUCCESS or TIMEOUT.
String SEND_PERMISSION Permission that's used to register the receiver to detect that the broadcaster is the SMS Retriever.
String SMS_RETRIEVED_ACTION Intent action when SMS message is retrieved.

Public Method Summary

static SmsRetrieverClient
getClient(Activity activity)
Create a new instance of SmsRetrieverClient for use in an Activity.
static SmsRetrieverClient
getClient(Context context)
Create a new instance of SmsRetrieverClient for use in an Context.

Inherited Method Summary

Constants

Intent extra key of the consent intent to be launched from client app.

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

public static final String EXTRA_SIM_SUBSCRIPTION_ID

[Optional] Intent extra key of the retrieved Sim card subscription Id if any, as an int.

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

public static final String EXTRA_SMS_MESSAGE

Intent extra key of the retrieved SMS message as a String.

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

public static final String EXTRA_STATUS

Intent extra key of Status, which indicates SUCCESS or TIMEOUT.

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

public static final String SEND_PERMISSION

Permission that's used to register the receiver to detect that the broadcaster is the SMS Retriever.

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

public static final String SMS_RETRIEVED_ACTION

Intent action when SMS message is retrieved.

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

Public Methods

public static SmsRetrieverClient getClient (Activity activity)

Create a new instance of SmsRetrieverClient for use in an Activity.

public static SmsRetrieverClient getClient (Context context)

Create a new instance of SmsRetrieverClient for use in an Context.