SmsManager
public
final
class
SmsManager
extends Object
| java.lang.Object | |
| ↳ | android.telephony.SmsManager |
Manages SMS operations such as sending data, text, and pdu SMS messages.
Get this object by calling the static method getDefault().
For information about how to behave as the default SMS app on Android 4.4 (API level 19)
and higher, see Telephony.
Summary
Nested classes | |
|---|---|
class |
SmsManager.FinancialSmsCallback
callback for providing asynchronous sms messages for financial app. |
Constants | |
|---|---|
String |
EXTRA_MMS_DATA
Intent extra name for MMS sending result data in byte array type |
String |
EXTRA_MMS_HTTP_STATUS
Intent extra name for HTTP status code for MMS HTTP failure in integer type |
String |
MMS_CONFIG_ALIAS_ENABLED
Whether alias is enabled (boolean type) |
String |
MMS_CONFIG_ALIAS_MAX_CHARS
Max alias character count (int type) |
String |
MMS_CONFIG_ALIAS_MIN_CHARS
Min alias character count (int type) |
String |
MMS_CONFIG_ALLOW_ATTACH_AUDIO
Whether audio is allowed to be attached for MMS messages (boolean type) |
String |
MMS_CONFIG_APPEND_TRANSACTION_ID
Whether to append transaction id to MMS WAP Push M-Notification.ind's content location URI when constructing the download URL of a new MMS (boolean type) |
String |
MMS_CONFIG_EMAIL_GATEWAY_NUMBER
Email gateway number (String type) |
String |
MMS_CONFIG_GROUP_MMS_ENABLED
Whether group MMS is enabled for the current carrier (boolean type) |
String |
MMS_CONFIG_HTTP_PARAMS
A list of HTTP headers to add to MMS HTTP request, separated by "|" (String type) |
String |
MMS_CONFIG_HTTP_SOCKET_TIMEOUT
MMS HTTP socket timeout in milliseconds (int type) |
String |
MMS_CONFIG_MAX_IMAGE_HEIGHT
Max MMS image height (int type) |
String |
MMS_CONFIG_MAX_IMAGE_WIDTH
Max MMS image width (int type) |
String |
MMS_CONFIG_MAX_MESSAGE_SIZE
Max MMS message size in bytes (int type) |
String |
MMS_CONFIG_MESSAGE_TEXT_MAX_SIZE
Max message text size (int type) |
String |
MMS_CONFIG_MMS_DELIVERY_REPORT_ENABLED
Whether MMS delivery report is enabled (boolean type) |
String |
MMS_CONFIG_MMS_ENABLED
Whether MMS is enabled for the current carrier (boolean type) |
String |
MMS_CONFIG_MMS_READ_REPORT_ENABLED
Whether MMS read report is enabled (boolean type) |
String |
MMS_CONFIG_MULTIPART_SMS_ENABLED
Whether multipart SMS is enabled (boolean type) |
String |
MMS_CONFIG_NAI_SUFFIX
The suffix to append to the NAI header value for MMS HTTP request (String type) |
String |
MMS_CONFIG_NOTIFY_WAP_MMSC_ENABLED
If this is enabled, M-NotifyResp.ind should be sent to the WAP Push content location instead of the default MMSC (boolean type) |
String |
MMS_CONFIG_RECIPIENT_LIMIT
Limit of recipients of MMS messages (int type) |
String |
MMS_CONFIG_SEND_MULTIPART_SMS_AS_SEPARATE_MESSAGES
Whether multipart SMS should be sent as separate messages |
String |
MMS_CONFIG_SHOW_CELL_BROADCAST_APP_LINKS
If true, show the cell broadcast (amber alert) in the SMS settings. |
String |
MMS_CONFIG_SMS_DELIVERY_REPORT_ENABLED
Whether SMS delivery report is enabled (boolean type) |
String |
MMS_CONFIG_SMS_TO_MMS_TEXT_LENGTH_THRESHOLD
Some carriers require SMS to be converted into MMS when text length reaches this threshold (int type) |
String |
MMS_CONFIG_SMS_TO_MMS_TEXT_THRESHOLD
When the number of parts of a multipart SMS reaches this threshold, it should be converted into an MMS (int type) |
String |
MMS_CONFIG_SUBJECT_MAX_LENGTH
Max message subject length (int type) |
String |
MMS_CONFIG_SUPPORT_HTTP_CHARSET_HEADER
Whether the carrier MMSC supports charset field in Content-Type header. |
String |
MMS_CONFIG_SUPPORT_MMS_CONTENT_DISPOSITION
Whether content-disposition field should be expected in an MMS PDU (boolean type) |
String |
MMS_CONFIG_UA_PROF_TAG_NAME
The name of the UA Prof URL HTTP header for MMS HTTP request (String type) |
String |
MMS_CONFIG_UA_PROF_URL
The UA Profile URL header value for MMS HTTP request (String type) |
String |
MMS_CONFIG_USER_AGENT
The User-Agent header value for MMS HTTP request (String type) |
int |
MMS_ERROR_CONFIGURATION_ERROR
|
int |
MMS_ERROR_HTTP_FAILURE
|
int |
MMS_ERROR_INVALID_APN
|
int |
MMS_ERROR_IO_ERROR
|
int |
MMS_ERROR_NO_DATA_NETWORK
|
int |
MMS_ERROR_RETRY
|
int |
MMS_ERROR_UNABLE_CONNECT_MMS
|
int |
MMS_ERROR_UNSPECIFIED
|
int |
RESULT_ERROR_GENERIC_FAILURE
Generic failure cause |
int |
RESULT_ERROR_LIMIT_EXCEEDED
Failed because we reached the sending queue limit. |
int |
RESULT_ERROR_NO_SERVICE
Failed because service is currently unavailable |
int |
RESULT_ERROR_NULL_PDU
Failed because no pdu provided |
int |
RESULT_ERROR_RADIO_OFF
Failed because radio was explicitly turned off |
int |
RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED
Failed because the user has denied this app ever send premium short codes. |
int |
RESULT_ERROR_SHORT_CODE_NOT_ALLOWED
Failed because user denied the sending of this short code. |
int |
STATUS_ON_ICC_FREE
Free space (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27). |
int |
STATUS_ON_ICC_READ
Received and read (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27). |
int |
STATUS_ON_ICC_SENT
Stored and sent (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27). |
int |
STATUS_ON_ICC_UNREAD
Received and unread (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27). |
int |
STATUS_ON_ICC_UNSENT
Stored and unsent (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27). |
Public methods | |
|---|---|
String
|
createAppSpecificSmsToken(PendingIntent intent)
Create a single use app specific incoming SMS request for the the calling package. |
String
|
createAppSpecificSmsTokenWithPackageInfo(String prefixes, PendingIntent intent)
Create a single use app specific incoming SMS request for the calling package. |
ArrayList<String>
|
divideMessage(String text)
Divide a message text into several fragments, none bigger than the maximum SMS message size. |
void
|
downloadMultimediaMessage(Context context, String locationUrl, Uri contentUri, Bundle configOverrides, PendingIntent downloadedIntent)
Download an MMS message from carrier by a given location URL |
Bundle
|
getCarrierConfigValues()
Get carrier-dependent configuration values. |
static
SmsManager
|
getDefault()
Get the SmsManager associated with the default subscription id. |
static
int
|
getDefaultSmsSubscriptionId()
Get default sms subscription id |
static
SmsManager
|
getSmsManagerForSubscriptionId(int subId)
Get the the instance of the SmsManager associated with a particular subscription id |
void
|
getSmsMessagesForFinancialApp(Bundle params, Executor executor, SmsManager.FinancialSmsCallback callback)
Get SMS messages for the calling financial app. |
int
|
getSubscriptionId()
Get the associated subscription id. |
void
|
injectSmsPdu(byte[] pdu, String format, PendingIntent receivedIntent)
Inject an SMS PDU into the android application framework. |
void
|
sendDataMessage(String destinationAddress, String scAddress, short destinationPort, byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent)
Send a data based SMS to a specific application port. |
void
|
sendMultimediaMessage(Context context, Uri contentUri, String locationUrl, Bundle configOverrides, PendingIntent sentIntent)
Send an MMS message |
void
|
sendMultipartTextMessage(String destinationAddress, String scAddress, ArrayList<String> parts, ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents)
Send a multi-part text based SMS. |
void
|
sendTextMessage(String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)
Send a text based SMS. |
void
|
sendTextMessageWithoutPersisting(String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)
Send a text based SMS without writing it into the SMS Provider. |
Inherited methods | |
|---|---|
Constants
EXTRA_MMS_DATA
public static final String EXTRA_MMS_DATA
Intent extra name for MMS sending result data in byte array type
Constant Value: "android.telephony.extra.MMS_DATA"
EXTRA_MMS_HTTP_STATUS
public static final String EXTRA_MMS_HTTP_STATUS
Intent extra name for HTTP status code for MMS HTTP failure in integer type
Constant Value: "android.telephony.extra.MMS_HTTP_STATUS"
MMS_CONFIG_ALIAS_ENABLED
public static final String MMS_CONFIG_ALIAS_ENABLED
Whether alias is enabled (boolean type)
Constant Value: "aliasEnabled"
MMS_CONFIG_ALIAS_MAX_CHARS
public static final String MMS_CONFIG_ALIAS_MAX_CHARS
Max alias character count (int type)
Constant Value: "aliasMaxChars"
MMS_CONFIG_ALIAS_MIN_CHARS
public static final String MMS_CONFIG_ALIAS_MIN_CHARS
Min alias character count (int type)
Constant Value: "aliasMinChars"
MMS_CONFIG_ALLOW_ATTACH_AUDIO
public static final String MMS_CONFIG_ALLOW_ATTACH_AUDIO
Whether audio is allowed to be attached for MMS messages (boolean type)
Constant Value: "allowAttachAudio"
MMS_CONFIG_APPEND_TRANSACTION_ID
public static final String MMS_CONFIG_APPEND_TRANSACTION_ID
Whether to append transaction id to MMS WAP Push M-Notification.ind's content location URI when constructing the download URL of a new MMS (boolean type)
Constant Value: "enabledTransID"
MMS_CONFIG_EMAIL_GATEWAY_NUMBER
public static final String MMS_CONFIG_EMAIL_GATEWAY_NUMBER
Email gateway number (String type)
Constant Value: "emailGatewayNumber"
MMS_CONFIG_GROUP_MMS_ENABLED
public static final String MMS_CONFIG_GROUP_MMS_ENABLED
Whether group MMS is enabled for the current carrier (boolean type)
Constant Value: "enableGroupMms"
MMS_CONFIG_HTTP_PARAMS
public static final String MMS_CONFIG_HTTP_PARAMS
A list of HTTP headers to add to MMS HTTP request, separated by "|" (String type)
Constant Value: "httpParams"
MMS_CONFIG_HTTP_SOCKET_TIMEOUT
public static final String MMS_CONFIG_HTTP_SOCKET_TIMEOUT
MMS HTTP socket timeout in milliseconds (int type)
Constant Value: "httpSocketTimeout"
MMS_CONFIG_MAX_IMAGE_HEIGHT
public static final String MMS_CONFIG_MAX_IMAGE_HEIGHT
Max MMS image height (int type)
Constant Value: "maxImageHeight"
MMS_CONFIG_MAX_IMAGE_WIDTH
public static final String MMS_CONFIG_MAX_IMAGE_WIDTH
Max MMS image width (int type)
Constant Value: "maxImageWidth"
MMS_CONFIG_MAX_MESSAGE_SIZE
public static final String MMS_CONFIG_MAX_MESSAGE_SIZE
Max MMS message size in bytes (int type)
Constant Value: "maxMessageSize"
MMS_CONFIG_MESSAGE_TEXT_MAX_SIZE
public static final String MMS_CONFIG_MESSAGE_TEXT_MAX_SIZE
Max message text size (int type)
Constant Value: "maxMessageTextSize"
MMS_CONFIG_MMS_DELIVERY_REPORT_ENABLED
public static final String MMS_CONFIG_MMS_DELIVERY_REPORT_ENABLED
Whether MMS delivery report is enabled (boolean type)
Constant Value: "enableMMSDeliveryReports"
MMS_CONFIG_MMS_ENABLED
public static final String MMS_CONFIG_MMS_ENABLED
Whether MMS is enabled for the current carrier (boolean type)
Constant Value: "enabledMMS"
MMS_CONFIG_MMS_READ_REPORT_ENABLED
public static final String MMS_CONFIG_MMS_READ_REPORT_ENABLED
Whether MMS read report is enabled (boolean type)
Constant Value: "enableMMSReadReports"
MMS_CONFIG_MULTIPART_SMS_ENABLED
public static final String MMS_CONFIG_MULTIPART_SMS_ENABLED
Whether multipart SMS is enabled (boolean type)
Constant Value: "enableMultipartSMS"
MMS_CONFIG_NAI_SUFFIX
public static final String MMS_CONFIG_NAI_SUFFIX
The suffix to append to the NAI header value for MMS HTTP request (String type)
Constant Value: "naiSuffix"
MMS_CONFIG_NOTIFY_WAP_MMSC_ENABLED
public static final String MMS_CONFIG_NOTIFY_WAP_MMSC_ENABLED
If this is enabled, M-NotifyResp.ind should be sent to the WAP Push content location instead of the default MMSC (boolean type)
Constant Value: "enabledNotifyWapMMSC"
MMS_CONFIG_RECIPIENT_LIMIT
public static final String MMS_CONFIG_RECIPIENT_LIMIT
Limit of recipients of MMS messages (int type)
Constant Value: "recipientLimit"
MMS_CONFIG_SEND_MULTIPART_SMS_AS_SEPARATE_MESSAGES
public static final String MMS_CONFIG_SEND_MULTIPART_SMS_AS_SEPARATE_MESSAGES
Whether multipart SMS should be sent as separate messages
Constant Value: "sendMultipartSmsAsSeparateMessages"
MMS_CONFIG_SHOW_CELL_BROADCAST_APP_LINKS
public static final String MMS_CONFIG_SHOW_CELL_BROADCAST_APP_LINKS
If true, show the cell broadcast (amber alert) in the SMS settings. Some carriers don't want this shown. (Boolean type)
Constant Value: "config_cellBroadcastAppLinks"
MMS_CONFIG_SMS_DELIVERY_REPORT_ENABLED
public static final String MMS_CONFIG_SMS_DELIVERY_REPORT_ENABLED
Whether SMS delivery report is enabled (boolean type)
Constant Value: "enableSMSDeliveryReports"
MMS_CONFIG_SMS_TO_MMS_TEXT_LENGTH_THRESHOLD
public static final String MMS_CONFIG_SMS_TO_MMS_TEXT_LENGTH_THRESHOLD
Some carriers require SMS to be converted into MMS when text length reaches this threshold (int type)
Constant Value: "smsToMmsTextLengthThreshold"
MMS_CONFIG_SMS_TO_MMS_TEXT_THRESHOLD
public static final String MMS_CONFIG_SMS_TO_MMS_TEXT_THRESHOLD
When the number of parts of a multipart SMS reaches this threshold, it should be converted into an MMS (int type)
Constant Value: "smsToMmsTextThreshold"
MMS_CONFIG_SUBJECT_MAX_LENGTH
public static final String MMS_CONFIG_SUBJECT_MAX_LENGTH
Max message subject length (int type)
Constant Value: "maxSubjectLength"
MMS_CONFIG_SUPPORT_HTTP_CHARSET_HEADER
public static final String MMS_CONFIG_SUPPORT_HTTP_CHARSET_HEADER
Whether the carrier MMSC supports charset field in Content-Type header. If this is false, then we don't add "charset" to "Content-Type"
Constant Value: "supportHttpCharsetHeader"
MMS_CONFIG_SUPPORT_MMS_CONTENT_DISPOSITION
public static final String MMS_CONFIG_SUPPORT_MMS_CONTENT_DISPOSITION
Whether content-disposition field should be expected in an MMS PDU (boolean type)
Constant Value: "supportMmsContentDisposition"
MMS_CONFIG_UA_PROF_TAG_NAME
public static final String MMS_CONFIG_UA_PROF_TAG_NAME
The name of the UA Prof URL HTTP header for MMS HTTP request (String type)
Constant Value: "uaProfTagName"
MMS_CONFIG_UA_PROF_URL
public static final String MMS_CONFIG_UA_PROF_URL
The UA Profile URL header value for MMS HTTP request (String type)
Constant Value: "uaProfUrl"
MMS_CONFIG_USER_AGENT
public static final String MMS_CONFIG_USER_AGENT
The User-Agent header value for MMS HTTP request (String type)
Constant Value: "userAgent"
MMS_ERROR_CONFIGURATION_ERROR
public static final int MMS_ERROR_CONFIGURATION_ERROR
Constant Value: 7 (0x00000007)
MMS_ERROR_HTTP_FAILURE
public static final int MMS_ERROR_HTTP_FAILURE
Constant Value: 4 (0x00000004)
MMS_ERROR_INVALID_APN
public static final int MMS_ERROR_INVALID_APN
Constant Value: 2 (0x00000002)
MMS_ERROR_IO_ERROR
public static final int MMS_ERROR_IO_ERROR
Constant Value: 5 (0x00000005)
MMS_ERROR_NO_DATA_NETWORK
public static final int MMS_ERROR_NO_DATA_NETWORK
Constant Value: 8 (0x00000008)
MMS_ERROR_RETRY
public static final int MMS_ERROR_RETRY
Constant Value: 6 (0x00000006)
MMS_ERROR_UNABLE_CONNECT_MMS
public static final int MMS_ERROR_UNABLE_CONNECT_MMS
Constant Value: 3 (0x00000003)
MMS_ERROR_UNSPECIFIED
public static final int MMS_ERROR_UNSPECIFIED
Constant Value: 1 (0x00000001)
RESULT_ERROR_GENERIC_FAILURE
public static final int RESULT_ERROR_GENERIC_FAILURE
Generic failure cause
Constant Value: 1 (0x00000001)
RESULT_ERROR_LIMIT_EXCEEDED
public static final int RESULT_ERROR_LIMIT_EXCEEDED
Failed because we reached the sending queue limit.
Constant Value: 5 (0x00000005)
RESULT_ERROR_NO_SERVICE
public static final int RESULT_ERROR_NO_SERVICE
Failed because service is currently unavailable
Constant Value: 4 (0x00000004)
RESULT_ERROR_NULL_PDU
public static final int RESULT_ERROR_NULL_PDU
Failed because no pdu provided
Constant Value: 3 (0x00000003)
RESULT_ERROR_RADIO_OFF
public static final int RESULT_ERROR_RADIO_OFF
Failed because radio was explicitly turned off
Constant Value: 2 (0x00000002)
RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED
public static final int RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED
Failed because the user has denied this app ever send premium short codes.
Constant Value: 8 (0x00000008)
RESULT_ERROR_SHORT_CODE_NOT_ALLOWED
public static final int RESULT_ERROR_SHORT_CODE_NOT_ALLOWED
Failed because user denied the sending of this short code.
Constant Value: 7 (0x00000007)
STATUS_ON_ICC_FREE
public static final int STATUS_ON_ICC_FREE
Free space (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27).
Constant Value: 0 (0x00000000)
STATUS_ON_ICC_READ
public static final int STATUS_ON_ICC_READ
Received and read (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27).
Constant Value: 1 (0x00000001)
STATUS_ON_ICC_SENT
public static final int STATUS_ON_ICC_SENT
Stored and sent (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27).
Constant Value: 5 (0x00000005)
STATUS_ON_ICC_UNREAD
public static final int STATUS_ON_ICC_UNREAD
Received and unread (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27).
Constant Value: 3 (0x00000003)
STATUS_ON_ICC_UNSENT
public static final int STATUS_ON_ICC_UNSENT
Stored and unsent (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27).
Constant Value: 7 (0x00000007)
Public methods
createAppSpecificSmsToken
public String createAppSpecificSmsToken (PendingIntent intent)
Create a single use app specific incoming SMS request for the the calling package.
This method returns a token that if included in a subsequent incoming SMS message will cause
intent to be sent with the SMS data.
The token is only good for one use, after an SMS has been received containing the token all
subsequent SMS messages with the token will be routed as normal.
An app can only have one request at a time, if the app already has a request pending it will
be replaced with a new request.
| Parameters | |
|---|---|
intent |
PendingIntent |
| Returns | |
|---|---|
String |
Token to include in an SMS message. The token will be 11 characters long. |
createAppSpecificSmsTokenWithPackageInfo
public String createAppSpecificSmsTokenWithPackageInfo (String prefixes, PendingIntent intent)
Create a single use app specific incoming SMS request for the calling package.
This method returns a token that if included in a subsequent incoming SMS message, and the
SMS message has a prefix from the given prefixes list, the provided intent will be
sent with the SMS data to the calling package.
The token is only good for one use within a reasonable amount of time. After an SMS has been
received containing the token all subsequent SMS messages with the token will be routed as
normal.
An app can only have one request at a time, if the app already has a request pending it will
be replaced with a new request.
| Parameters | |
|---|---|
prefixes |
String: this is a list of prefixes string separated by REGEX_PREFIX_DELIMITER. The
matching SMS message should have at least one of the prefixes in the beginning of the
message.
This value may be null. |
intent |
PendingIntent: this intent is sent when the matching SMS message is received.
This value must never be null. |
| Returns | |
|---|---|
String |
Token to include in an SMS message.
This value may be null. |
divideMessage
public ArrayList<String> divideMessage (String text)
Divide a message text into several fragments, none bigger than the maximum SMS message size.
| Parameters | |
|---|---|
text |
String: the original message. Must not be null. |
| Returns | |
|---|---|
ArrayList<String> |
an ArrayList of strings that, in order,
comprise the original message |
| Throws | |
|---|---|
IllegalArgumentException |
if text is null |
downloadMultimediaMessage
public void downloadMultimediaMessage (Context context, String locationUrl, Uri contentUri, Bundle configOverrides, PendingIntent downloadedIntent)
Download an MMS message from carrier by a given location URL
| Parameters | |
|---|---|
context |
Context: application context |
locationUrl |
String: the location URL of the MMS message to be downloaded, usually obtained
from the MMS WAP push notification |
contentUri |
Uri: the content uri to which the downloaded pdu will be written |
configOverrides |
Bundle: the carrier-specific messaging configuration values to override for
downloading the message. |
downloadedIntent |
PendingIntent: if not NULL this PendingIntent is
broadcast when the message is downloaded, or the download is failed |
| Throws | |
|---|---|
IllegalArgumentException |
if locationUrl or contentUri is empty |
getCarrierConfigValues
public Bundle getCarrierConfigValues ()
Get carrier-dependent configuration values.
| Returns | |
|---|---|
Bundle |
bundle key/values pairs of configuration values |
getDefault
public static SmsManager getDefault ()
Get the SmsManager associated with the default subscription id. The instance will always be associated with the default subscription id, even if the default subscription id is changed.
| Returns | |
|---|---|
SmsManager |
the SmsManager associated with the default subscription id |
getDefaultSmsSubscriptionId
public static int getDefaultSmsSubscriptionId ()
Get default sms subscription id
| Returns | |
|---|---|
int |
the default SMS subscription id |
getSmsManagerForSubscriptionId
public static SmsManager getSmsManagerForSubscriptionId (int subId)
Get the the instance of the SmsManager associated with a particular subscription id
| Parameters | |
|---|---|
subId |
int: an SMS subscription id, typically accessed using
SubscriptionManager |
| Returns | |
|---|---|
SmsManager |
the instance of the SmsManager associated with subId |
getSmsMessagesForFinancialApp
public void getSmsMessagesForFinancialApp (Bundle params, Executor executor, SmsManager.FinancialSmsCallback callback)
Get SMS messages for the calling financial app.
The result will be delivered asynchronously in the passing in callback interface.
Requires Manifest.permission.SMS_FINANCIAL_TRANSACTIONS
| Parameters | |
|---|---|
params |
Bundle: the parameters to filter SMS messages returned. |
executor |
Executor: the executor on which callback will be invoked.
This value must never be null.
Callback and listener events are dispatched through this
Executor, providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use Context#getMainExecutor(). To
dispatch events through a shared thread pool, you can use
AsyncTask#THREAD_POOL_EXECUTOR. |
callback |
SmsManager.FinancialSmsCallback: a callback to receive CursorWindow with SMS messages.
This value must never be null. |
getSubscriptionId
public int getSubscriptionId ()
Get the associated subscription id. If the instance was returned by getDefault(),
then this method may return different values at different points in time (if the user
changes the default subscription id). It will return < 0 if the default subscription id
cannot be determined.
Additionally, to support legacy applications that are not multi-SIM aware,
if the following are true:
- We are using a multi-SIM device
- A default SMS SIM has not been selected
- At least one SIM subscription is available
then ask the user to set the default SMS SIM.
| Returns | |
|---|---|
int |
associated subscription id |
injectSmsPdu
public void injectSmsPdu (byte[] pdu,
String format,
PendingIntent receivedIntent)
Inject an SMS PDU into the android application framework.
Requires permission: Manifest.permission.MODIFY_PHONE_STATE or carrier
privileges per TelephonyManager.hasCarrierPrivileges().
| Parameters | |
|---|---|
pdu |
byte: is the byte array of pdu to be injected into android application framework |
format |
String: is the format of SMS pdu (SmsMessage#FORMAT_3GPP or
SmsMessage#FORMAT_3GPP2)
Value is SmsMessage.FORMAT_3GPP, or SmsMessage.FORMAT_3GPP2 |
receivedIntent |
PendingIntent: if not NULL this PendingIntent is
broadcast when the message is successfully received by the
android application framework, or failed. This intent is broadcasted at
the same time an SMS received from radio is acknowledged back.
The result code will be Telephony.Sms.Intents.RESULT_SMS_HANDLED
for success, or Telephony.Sms.Intents.RESULT_SMS_GENERIC_ERROR for
error. |
| Throws | |
|---|---|
IllegalArgumentException |
if the format is invalid. |
sendDataMessage
public void sendDataMessage (String destinationAddress, String scAddress, short destinationPort, byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent)
Send a data based SMS to a specific application port.
Note: Using this method requires that your app has the
Manifest.permission.SEND_SMS permission.
| Parameters | |
|---|---|
destinationAddress |
String: the address to send the message to |
scAddress |
String: is the service center address or null to use
the current default SMSC |
destinationPort |
short: the port to deliver the message to |
data |
byte: the body of the message to send |
sentIntent |
PendingIntent: if not NULL this PendingIntent is
broadcast when the message is successfully sent, or failed.
The result code will be Activity.RESULT_OK for success,
or one of these errors:RESULT_ERROR_GENERIC_FAILURERESULT_ERROR_RADIO_OFFRESULT_ERROR_NULL_PDUFor RESULT_ERROR_GENERIC_FAILURE the sentIntent may include
the extra "errorCode" containing a radio technology specific value,
generally only useful for troubleshooting.The per-application based SMS control checks sentIntent. If sentIntent is NULL the caller will be checked against all unknown applications, which cause smaller number of SMS to be sent in checking period. |
deliveryIntent |
PendingIntent: if not NULL this PendingIntent is
broadcast when the message is delivered to the recipient. The
raw pdu of the status report is in the extended data ("pdu"). |
| Throws | |
|---|---|
IllegalArgumentException |
if destinationAddress or data are empty |
sendMultimediaMessage
public void sendMultimediaMessage (Context context, Uri contentUri, String locationUrl, Bundle configOverrides, PendingIntent sentIntent)
Send an MMS message
| Parameters | |
|---|---|
context |
Context: application context |
contentUri |
Uri: the content Uri from which the message pdu will be read |
locationUrl |
String: the optional location url where message should be sent to |
configOverrides |
Bundle: the carrier-specific messaging configuration values to override for
sending the message. |
sentIntent |
PendingIntent: if not NULL this PendingIntent is
broadcast when the message is successfully sent, or failed |
| Throws | |
|---|---|
IllegalArgumentException |
if contentUri is empty |
sendMultipartTextMessage
public void sendMultipartTextMessage (String destinationAddress, String scAddress, ArrayList<String> parts, ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents)
Send a multi-part text based SMS. The callee should have already
divided the message into correctly sized parts by calling
divideMessage.
Note: Using this method requires that your app has the
Manifest.permission.SEND_SMS permission.
Note: Beginning with Android 4.4 (API level 19), if
and only if an app is not selected as the default SMS app, the system automatically
writes messages sent using this method to the SMS Provider (the default SMS app is always
responsible for writing its sent messages to the SMS Provider). For information about
how to behave as the default SMS app, see Telephony.
| Parameters | |
|---|---|
destinationAddress |
String: the address to send the message to |
scAddress |
String: is the service center address or null to use
the current default SMSC |
parts |
ArrayList: an ArrayList of strings that, in order,
comprise the original message |
sentIntents |
ArrayList: if not null, an ArrayList of
PendingIntents (one for each message part) that is
broadcast when the corresponding message part has been sent.
The result code will be Activity.RESULT_OK for success,
or one of these errors:RESULT_ERROR_GENERIC_FAILURERESULT_ERROR_RADIO_OFFRESULT_ERROR_NULL_PDUFor RESULT_ERROR_GENERIC_FAILURE each sentIntent may include
the extra "errorCode" containing a radio technology specific value,
generally only useful for troubleshooting.The per-application based SMS control checks sentIntent. If sentIntent is NULL the caller will be checked against all unknown applications, which cause smaller number of SMS to be sent in checking period. |
deliveryIntents |
ArrayList: if not null, an ArrayList of
PendingIntents (one for each message part) that is
broadcast when the corresponding message part has been delivered
to the recipient. The raw pdu of the status report is in the
extended data ("pdu"). |
| Throws | |
|---|---|
IllegalArgumentException |
if destinationAddress or data are empty |
sendTextMessage
public void sendTextMessage (String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)
Send a text based SMS.
Note: Using this method requires that your app has the
Manifest.permission.SEND_SMS permission.
Note: Beginning with Android 4.4 (API level 19), if
and only if an app is not selected as the default SMS app, the system automatically
writes messages sent using this method to the SMS Provider (the default SMS app is always
responsible for writing its sent messages to the SMS Provider). For information about
how to behave as the default SMS app, see Telephony.
| Parameters | |
|---|---|
destinationAddress |
String: the address to send the message to |
scAddress |
String: is the service center address or null to use
the current default SMSC |
text |
String: the body of the message to send |
sentIntent |
PendingIntent: if not NULL this PendingIntent is
broadcast when the message is successfully sent, or failed.
The result code will be Activity.RESULT_OK for success,
or one of these errors:RESULT_ERROR_GENERIC_FAILURERESULT_ERROR_RADIO_OFFRESULT_ERROR_NULL_PDUFor RESULT_ERROR_GENERIC_FAILURE the sentIntent may include
the extra "errorCode" containing a radio technology specific value,
generally only useful for troubleshooting.The per-application based SMS control checks sentIntent. If sentIntent is NULL the caller will be checked against all unknown applications, which cause smaller number of SMS to be sent in checking period. |
deliveryIntent |
PendingIntent: if not NULL this PendingIntent is
broadcast when the message is delivered to the recipient. The
raw pdu of the status report is in the extended data ("pdu"). |
| Throws | |
|---|---|
IllegalArgumentException |
if destinationAddress or text are empty |
sendTextMessageWithoutPersisting
public void sendTextMessageWithoutPersisting (String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)
Send a text based SMS without writing it into the SMS Provider.
The message will be sent directly over the network and will not be visible in SMS applications. Intended for internal carrier use only.
Requires Permission: Both Manifest.permission.SEND_SMS and
Manifest.permission.MODIFY_PHONE_STATE, or that the calling app has carrier
privileges (see TelephonyManager#hasCarrierPrivileges), or that the calling app is
the default IMS app (see
CarrierConfigManager#KEY_CONFIG_IMS_PACKAGE_OVERRIDE_STRING).
Requires Manifest.permission.MODIFY_PHONE_STATE and Manifest.permission.SEND_SMS
| Parameters | |
|---|---|
destinationAddress |
String |
scAddress |
String |
text |
String |
sentIntent |
PendingIntent |
deliveryIntent |
PendingIntent |
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.