public final class

SmsRetriever

extends Object
java.lang.Object
   ↳ com.google.android.gms.auth.api.phone.SmsRetriever

Class Overview

The SmsRetriever API provides access to Google services that help you retrieve the SMS message directed to your app without asking for android.permission.READ_SMS.

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

The received SMS message will be sent via a Broadcast Intent with action SmsRetriever.SMS_RETRIEVED_ACTION. The Intent contains Extras with keys SmsRetriever.EXTRA_SMS_MESSAGE for the SMS message string and SmsRetriever.EXTRA_STATUS for the Status to indicate SUCCESS, DEVELOPER_ERROR, ERROR, or TIMEOUT.

The possible causes for errors are:

  • DEVELOPER_ERROR: the caller app has incorrect number of certificates. Only one certificate is allowed.
  • ERROR: the AppCode collides with other installed apps.

Summary

Constants
String EXTRA_SMS_MESSAGE Intent extra key of SMS message
String EXTRA_STATUS Intent extra key of Status, which indicates SUCCESS or TIMEOUT
String SMS_RETRIEVED_ACTION Intent action when SMS message is retrieved.
Public Methods
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.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String EXTRA_SMS_MESSAGE

Intent extra key of SMS message

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

Parameters
activity Activity
Returns
SmsRetrieverClient

public static SmsRetrieverClient getClient (Context context)

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

Parameters
context Context
Returns
SmsRetrieverClient