public final class SmsManager extends Object
getDefault()
.
For information about how to behave as the default SMS app on Android 4.4 (API level 19)
and higher, see Telephony
.
Modifier and Type | Field and Description |
---|---|
static int |
CELL_BROADCAST_RAN_TYPE_CDMA |
static int |
CELL_BROADCAST_RAN_TYPE_GSM |
static String |
EXTRA_MMS_DATA
Intent extra name for MMS sending result data in byte array type
|
static String |
EXTRA_MMS_HTTP_STATUS
Intent extra name for HTTP status code for MMS HTTP failure in integer type
|
static String |
MESSAGE_STATUS_READ
Message status property: whether the message has been read. 1 means read, 0 not
|
static String |
MESSAGE_STATUS_SEEN
Message status property: whether the message has been seen. 1 means seen, 0 not
|
static String |
MMS_CONFIG_ALIAS_ENABLED
Whether alias is enabled (boolean type)
|
static String |
MMS_CONFIG_ALIAS_MAX_CHARS
Max alias character count (int type)
|
static String |
MMS_CONFIG_ALIAS_MIN_CHARS
Min alias character count (int type)
|
static String |
MMS_CONFIG_ALLOW_ATTACH_AUDIO
Whether audio is allowed to be attached for MMS messages (boolean type)
|
static 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)
|
static String |
MMS_CONFIG_CLOSE_CONNECTION
If true, add "Connection: close" header to MMS HTTP requests so the connection
is immediately closed (disabling keep-alive).
|
static String |
MMS_CONFIG_EMAIL_GATEWAY_NUMBER
Email gateway number (String type)
|
static String |
MMS_CONFIG_GROUP_MMS_ENABLED
Whether group MMS is enabled for the current carrier (boolean type)
|
static String |
MMS_CONFIG_HTTP_PARAMS
A list of HTTP headers to add to MMS HTTP request, separated by "|" (String type)
|
static String |
MMS_CONFIG_HTTP_SOCKET_TIMEOUT
MMS HTTP socket timeout in milliseconds (int type)
|
static String |
MMS_CONFIG_MAX_IMAGE_HEIGHT
Max MMS image height (int type)
|
static String |
MMS_CONFIG_MAX_IMAGE_WIDTH
Max MMS image width (int type)
|
static String |
MMS_CONFIG_MAX_MESSAGE_SIZE
Max MMS message size in bytes (int type)
|
static String |
MMS_CONFIG_MESSAGE_TEXT_MAX_SIZE
Max message text size (int type)
|
static String |
MMS_CONFIG_MMS_DELIVERY_REPORT_ENABLED
Whether MMS delivery report is enabled (boolean type)
|
static String |
MMS_CONFIG_MMS_ENABLED
Whether MMS is enabled for the current carrier (boolean type)
|
static String |
MMS_CONFIG_MMS_READ_REPORT_ENABLED
Whether MMS read report is enabled (boolean type)
|
static String |
MMS_CONFIG_MULTIPART_SMS_ENABLED
Whether multipart SMS is enabled (boolean type)
|
static String |
MMS_CONFIG_NAI_SUFFIX
The suffix to append to the NAI header value for MMS HTTP request (String type)
|
static 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)
|
static String |
MMS_CONFIG_RECIPIENT_LIMIT
Limit of recipients of MMS messages (int type)
|
static String |
MMS_CONFIG_SEND_MULTIPART_SMS_AS_SEPARATE_MESSAGES
Whether multipart SMS should be sent as separate messages
|
static String |
MMS_CONFIG_SHOW_CELL_BROADCAST_APP_LINKS
If true, show the cell broadcast (amber alert) in the SMS settings.
|
static String |
MMS_CONFIG_SMS_DELIVERY_REPORT_ENABLED
Whether SMS delivery report is enabled (boolean type)
|
static 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)
|
static 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)
|
static String |
MMS_CONFIG_SUBJECT_MAX_LENGTH
Max message subject length (int type)
|
static String |
MMS_CONFIG_SUPPORT_HTTP_CHARSET_HEADER
Whether the carrier MMSC supports charset field in Content-Type header.
|
static String |
MMS_CONFIG_SUPPORT_MMS_CONTENT_DISPOSITION
Whether content-disposition field should be expected in an MMS PDU (boolean type)
|
static String |
MMS_CONFIG_UA_PROF_TAG_NAME
The name of the UA Prof URL HTTP header for MMS HTTP request (String type)
|
static String |
MMS_CONFIG_UA_PROF_URL
The UA Profile URL header value for MMS HTTP request (String type)
|
static String |
MMS_CONFIG_USER_AGENT
The User-Agent header value for MMS HTTP request (String type)
|
static int |
MMS_ERROR_CONFIGURATION_ERROR |
static int |
MMS_ERROR_HTTP_FAILURE |
static int |
MMS_ERROR_INVALID_APN |
static int |
MMS_ERROR_IO_ERROR |
static int |
MMS_ERROR_NO_DATA_NETWORK |
static int |
MMS_ERROR_RETRY |
static int |
MMS_ERROR_UNABLE_CONNECT_MMS |
static int |
MMS_ERROR_UNSPECIFIED |
static int |
RESULT_ERROR_FDN_CHECK_FAILURE
Failed because FDN is enabled.
|
static int |
RESULT_ERROR_GENERIC_FAILURE
Generic failure cause
|
static int |
RESULT_ERROR_LIMIT_EXCEEDED
Failed because we reached the sending queue limit.
|
static int |
RESULT_ERROR_NO_SERVICE
Failed because service is currently unavailable
|
static int |
RESULT_ERROR_NULL_PDU
Failed because no pdu provided
|
static int |
RESULT_ERROR_RADIO_OFF
Failed because radio was explicitly turned off
|
static int |
SMS_TYPE_INCOMING
Represents the received SMS message for importing
|
static int |
SMS_TYPE_OUTGOING
Represents the sent SMS message for importing
|
static int |
STATUS_ON_ICC_FREE
Free space (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27).
|
static int |
STATUS_ON_ICC_READ
Received and read (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27).
|
static int |
STATUS_ON_ICC_SENT
Stored and sent (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27).
|
static int |
STATUS_ON_ICC_UNREAD
Received and unread (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27).
|
static int |
STATUS_ON_ICC_UNSENT
Stored and unsent (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27).
|
Modifier and Type | Method and Description |
---|---|
Uri |
addMultimediaMessageDraft(Uri contentUri)
Add a multimedia message draft to system MMS store
Only default SMS apps can add MMS draft
|
Uri |
addTextMessageDraft(String address,
String text)
Add a text message draft to system SMS store
Only default SMS apps can add SMS draft
|
boolean |
archiveStoredConversation(long conversationId,
boolean archived)
Archive or unarchive a stored conversation
|
boolean |
copyMessageToIcc(byte[] smsc,
byte[] pdu,
int status)
Copy a raw SMS PDU to the ICC.
|
boolean |
deleteMessageFromIcc(int messageIndex)
Delete the specified message from the ICC.
|
boolean |
deleteStoredConversation(long conversationId)
Delete a system stored SMS or MMS thread
Only default SMS apps can delete system stored SMS and MMS conversations
|
boolean |
deleteStoredMessage(Uri messageUri)
Delete a system stored SMS or MMS message
Only default SMS apps can delete system stored SMS and MMS messages
|
boolean |
disableCellBroadcast(int messageIdentifier,
int ranType)
Disable reception of cell broadcast (SMS-CB) messages with the given
message identifier and RAN type.
|
boolean |
disableCellBroadcastRange(int startMessageId,
int endMessageId,
int ranType)
Disable reception of cell broadcast (SMS-CB) messages with the given
message identifier range and RAN type.
|
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
|
boolean |
enableCellBroadcast(int messageIdentifier,
int ranType)
Enable reception of cell broadcast (SMS-CB) messages with the given
message identifier and RAN type.
|
boolean |
enableCellBroadcastRange(int startMessageId,
int endMessageId,
int ranType)
Enable reception of cell broadcast (SMS-CB) messages with the given
message identifier range and RAN type.
|
ArrayList<SmsMessage> |
getAllMessagesFromIcc()
Retrieves all messages currently stored on ICC.
|
boolean |
getAutoPersisting()
Get the value of the flag to automatically write sent/received SMS/MMS messages into system
When this flag is on, all SMS/MMS sent/received are stored by system automatically
When this flag is off, only SMS/MMS sent by non-default SMS apps are stored by system
automatically
|
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
|
String |
getImsSmsFormat()
Gets SMS format supported on IMS.
|
static Bundle |
getMmsConfig(BaseBundle config)
Filters a bundle to only contain MMS config variables.
|
static SmsManager |
getSmsManagerForSubscriptionId(int subId)
Get the the instance of the SmsManager associated with a particular subscription id
|
int |
getSubscriptionId()
Get the associated subscription id.
|
Uri |
importMultimediaMessage(Uri contentUri,
String messageId,
long timestampSecs,
boolean seen,
boolean read)
Import a multimedia message into system's MMS store.
|
Uri |
importTextMessage(String address,
int type,
String text,
long timestampMillis,
boolean seen,
boolean read)
Import a text message into system's SMS store
Only default SMS apps can import SMS
|
void |
injectSmsPdu(byte[] pdu,
String format,
PendingIntent receivedIntent)
Inject an SMS PDU into the android application framework.
|
boolean |
isImsSmsSupported()
SMS over IMS is supported if IMS is registered and SMS is supported
on IMS.
|
boolean |
isSMSPromptEnabled()
Get SMS prompt property, enabled or not
|
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 |
sendDataMessageWithSelfPermissions(String destinationAddress,
String scAddress,
short destinationPort,
byte[] data,
PendingIntent sentIntent,
PendingIntent deliveryIntent)
A variant of
sendDataMessage(java.lang.String, java.lang.String, short, byte[], android.app.PendingIntent, android.app.PendingIntent) that allows self to be the caller. |
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 |
sendMultipartTextMessageWithoutPersisting(String destinationAddress,
String scAddress,
ArrayList<String> parts,
ArrayList<PendingIntent> sentIntents,
ArrayList<PendingIntent> deliveryIntents)
Send a multi-part text based SMS without writing it into the SMS Provider.
|
void |
sendStoredMultimediaMessage(Uri messageUri,
Bundle configOverrides,
PendingIntent sentIntent)
Send a system stored MMS message
This is used for sending a previously sent, but failed-to-send, message or
for sending a text message that has been stored as a draft.
|
void |
sendStoredMultipartTextMessage(Uri messageUri,
String scAddress,
ArrayList<PendingIntent> sentIntents,
ArrayList<PendingIntent> deliveryIntents)
Send a system stored multi-part text message.
|
void |
sendStoredTextMessage(Uri messageUri,
String scAddress,
PendingIntent sentIntent,
PendingIntent deliveryIntent)
Send a system stored text message.
|
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.
|
void |
sendTextMessageWithSelfPermissions(String destinationAddress,
String scAddress,
String text,
PendingIntent sentIntent,
PendingIntent deliveryIntent,
boolean persistMessage)
A variant of
sendTextMessage(java.lang.String, java.lang.String, java.lang.String, android.app.PendingIntent, android.app.PendingIntent) that allows self to be the caller. |
void |
setAutoPersisting(boolean enabled)
Turns on/off the flag to automatically write sent/received SMS/MMS messages into system
When this flag is on, all SMS/MMS sent/received are stored by system automatically
When this flag is off, only SMS/MMS sent by non-default SMS apps are stored by system
automatically
This flag can only be changed by default SMS apps
|
boolean |
updateMessageOnIcc(int messageIndex,
int newStatus,
byte[] pdu)
Update the specified message on the ICC.
|
boolean |
updateStoredMessageStatus(Uri messageUri,
ContentValues statusValues)
Update the status properties of a system stored SMS or MMS message, e.g.
|
public static final int CELL_BROADCAST_RAN_TYPE_GSM
public static final int CELL_BROADCAST_RAN_TYPE_CDMA
public static final String MMS_CONFIG_APPEND_TRANSACTION_ID
public static final String MMS_CONFIG_MMS_ENABLED
public static final String MMS_CONFIG_GROUP_MMS_ENABLED
public static final String MMS_CONFIG_NOTIFY_WAP_MMSC_ENABLED
public static final String MMS_CONFIG_ALIAS_ENABLED
public static final String MMS_CONFIG_ALLOW_ATTACH_AUDIO
public static final String MMS_CONFIG_MULTIPART_SMS_ENABLED
public static final String MMS_CONFIG_SMS_DELIVERY_REPORT_ENABLED
public static final String MMS_CONFIG_SUPPORT_MMS_CONTENT_DISPOSITION
public static final String MMS_CONFIG_SEND_MULTIPART_SMS_AS_SEPARATE_MESSAGES
public static final String MMS_CONFIG_MMS_READ_REPORT_ENABLED
public static final String MMS_CONFIG_MMS_DELIVERY_REPORT_ENABLED
public static final String MMS_CONFIG_MAX_MESSAGE_SIZE
public static final String MMS_CONFIG_MAX_IMAGE_WIDTH
public static final String MMS_CONFIG_MAX_IMAGE_HEIGHT
public static final String MMS_CONFIG_RECIPIENT_LIMIT
public static final String MMS_CONFIG_ALIAS_MIN_CHARS
public static final String MMS_CONFIG_ALIAS_MAX_CHARS
public static final String MMS_CONFIG_SMS_TO_MMS_TEXT_THRESHOLD
public static final String MMS_CONFIG_SMS_TO_MMS_TEXT_LENGTH_THRESHOLD
public static final String MMS_CONFIG_MESSAGE_TEXT_MAX_SIZE
public static final String MMS_CONFIG_SUBJECT_MAX_LENGTH
public static final String MMS_CONFIG_HTTP_SOCKET_TIMEOUT
public static final String MMS_CONFIG_UA_PROF_TAG_NAME
public static final String MMS_CONFIG_USER_AGENT
public static final String MMS_CONFIG_UA_PROF_URL
public static final String MMS_CONFIG_HTTP_PARAMS
public static final String MMS_CONFIG_EMAIL_GATEWAY_NUMBER
public static final String MMS_CONFIG_NAI_SUFFIX
public static final String MMS_CONFIG_SHOW_CELL_BROADCAST_APP_LINKS
public static final String MMS_CONFIG_SUPPORT_HTTP_CHARSET_HEADER
public static final String MMS_CONFIG_CLOSE_CONNECTION
public static final int STATUS_ON_ICC_FREE
public static final int STATUS_ON_ICC_READ
public static final int STATUS_ON_ICC_UNREAD
public static final int STATUS_ON_ICC_SENT
public static final int STATUS_ON_ICC_UNSENT
public static final int RESULT_ERROR_GENERIC_FAILURE
public static final int RESULT_ERROR_RADIO_OFF
public static final int RESULT_ERROR_NULL_PDU
public static final int RESULT_ERROR_NO_SERVICE
public static final int RESULT_ERROR_LIMIT_EXCEEDED
public static final int RESULT_ERROR_FDN_CHECK_FAILURE
public static final int MMS_ERROR_UNSPECIFIED
public static final int MMS_ERROR_INVALID_APN
public static final int MMS_ERROR_UNABLE_CONNECT_MMS
public static final int MMS_ERROR_HTTP_FAILURE
public static final int MMS_ERROR_IO_ERROR
public static final int MMS_ERROR_RETRY
public static final int MMS_ERROR_CONFIGURATION_ERROR
public static final int MMS_ERROR_NO_DATA_NETWORK
public static final String EXTRA_MMS_DATA
public static final String EXTRA_MMS_HTTP_STATUS
public static final int SMS_TYPE_INCOMING
public static final int SMS_TYPE_OUTGOING
public static final String MESSAGE_STATUS_SEEN
public static final String MESSAGE_STATUS_READ
public void sendTextMessage(String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)
Note: Using this method requires that your app has the
android.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
.
destinationAddress
- the address to send the message toscAddress
- is the service center address or null to use
the current default SMSCtext
- the body of the message to sendsentIntent
- 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_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
RESULT_ERROR_GENERIC_FAILURE
the sentIntent may include
the extra "errorCode" containing a radio technology specific value,
generally only useful for troubleshooting.deliveryIntent
- 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").IllegalArgumentException
- if destinationAddress or text are emptypublic void sendTextMessageWithoutPersisting(String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)
Only the carrier app can call this method.
public void sendTextMessageWithSelfPermissions(String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent, boolean persistMessage)
sendTextMessage(java.lang.String, java.lang.String, java.lang.String, android.app.PendingIntent, android.app.PendingIntent)
that allows self to be the caller. This is
for internal use only.persistMessage
- whether to persist the sent message in the SMS app. the caller must be
the Phone process if set to false.public void injectSmsPdu(byte[] pdu, String format, PendingIntent receivedIntent)
pdu
- is the byte array of pdu to be injected into android application frameworkformat
- is the format of SMS pdu (3gpp or 3gpp2)receivedIntent
- 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 RESULT_SMS_HANDLED
for success, or
RESULT_SMS_GENERIC_ERROR
for error.IllegalArgumentException
- if format is not one of 3gpp and 3gpp2.TelephonyManager.hasCarrierPrivileges()
public ArrayList<String> divideMessage(String text)
text
- the original message. Must not be null.ArrayList
of strings that, in order,
comprise the original messageIllegalArgumentException
- if text is nullpublic void sendMultipartTextMessage(String destinationAddress, String scAddress, ArrayList<String> parts, ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents)
divideMessage
.
Note: Using this method requires that your app has the
android.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
.
destinationAddress
- the address to send the message toscAddress
- is the service center address or null to use
the current default SMSCparts
- an ArrayList
of strings that, in order,
comprise the original messagesentIntents
- if not null, an ArrayList
of
PendingIntent
s (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_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
RESULT_ERROR_GENERIC_FAILURE
each sentIntent may include
the extra "errorCode" containing a radio technology specific value,
generally only useful for troubleshooting.deliveryIntents
- if not null, an ArrayList
of
PendingIntent
s (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").IllegalArgumentException
- if destinationAddress or data are emptypublic void sendMultipartTextMessageWithoutPersisting(String destinationAddress, String scAddress, ArrayList<String> parts, ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents)
Only the carrier app can call this method.
public void sendDataMessage(String destinationAddress, String scAddress, short destinationPort, byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent)
Note: Using this method requires that your app has the
android.Manifest.permission#SEND_SMS
permission.
destinationAddress
- the address to send the message toscAddress
- is the service center address or null to use
the current default SMSCdestinationPort
- the port to deliver the message todata
- the body of the message to sendsentIntent
- 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_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
RESULT_ERROR_GENERIC_FAILURE
the sentIntent may include
the extra "errorCode" containing a radio technology specific value,
generally only useful for troubleshooting.deliveryIntent
- 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").IllegalArgumentException
- if destinationAddress or data are emptypublic void sendDataMessageWithSelfPermissions(String destinationAddress, String scAddress, short destinationPort, byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent)
sendDataMessage(java.lang.String, java.lang.String, short, byte[], android.app.PendingIntent, android.app.PendingIntent)
that allows self to be the caller. This is
for internal use only.public static SmsManager getDefault()
public static SmsManager getSmsManagerForSubscriptionId(int subId)
subId
- an SMS subscription id, typically accessed using
SubscriptionManager
public int getSubscriptionId()
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.public boolean copyMessageToIcc(byte[] smsc, byte[] pdu, int status)
smsc
- the SMSC for this message, or NULL for the default SMSCpdu
- the raw PDU to storestatus
- message status (STATUS_ON_ICC_READ, STATUS_ON_ICC_UNREAD,
STATUS_ON_ICC_SENT, STATUS_ON_ICC_UNSENT)IllegalArgumentException
- if pdu is NULL
public boolean deleteMessageFromIcc(int messageIndex)
messageIndex
- is the record index of the message on ICCpublic boolean updateMessageOnIcc(int messageIndex, int newStatus, byte[] pdu)
messageIndex
- record index of message to updatenewStatus
- new message status (STATUS_ON_ICC_READ,
STATUS_ON_ICC_UNREAD, STATUS_ON_ICC_SENT,
STATUS_ON_ICC_UNSENT, STATUS_ON_ICC_FREE)pdu
- the raw PDU to storepublic ArrayList<SmsMessage> getAllMessagesFromIcc()
ArrayList
of SmsMessage
objects
public boolean enableCellBroadcast(int messageIdentifier, int ranType)
messageIdentifier
- Message identifier as specified in TS 23.041 (3GPP)
or C.R1001-G (3GPP2)ranType
- as defined in class SmsManager, the value can be one of these:
android.telephony.SmsMessage.CELL_BROADCAST_RAN_TYPE_GSM
android.telephony.SmsMessage.CELL_BROADCAST_RAN_TYPE_CDMA{@hide}
public boolean disableCellBroadcast(int messageIdentifier, int ranType)
messageIdentifier
- Message identifier as specified in TS 23.041 (3GPP)
or C.R1001-G (3GPP2)ranType
- as defined in class SmsManager, the value can be one of these:
android.telephony.SmsMessage.CELL_BROADCAST_RAN_TYPE_GSM
android.telephony.SmsMessage.CELL_BROADCAST_RAN_TYPE_CDMA{@hide}
public boolean enableCellBroadcastRange(int startMessageId, int endMessageId, int ranType)
startMessageId
- first message identifier as specified in TS 23.041 (3GPP)
or C.R1001-G (3GPP2)endMessageId
- last message identifier as specified in TS 23.041 (3GPP)
or C.R1001-G (3GPP2)ranType
- as defined in class SmsManager, the value can be one of these:
android.telephony.SmsMessage.CELL_BROADCAST_RAN_TYPE_GSM
android.telephony.SmsMessage.CELL_BROADCAST_RAN_TYPE_CDMAIllegalArgumentException
- if endMessageId < startMessageId
disableCellBroadcastRange(int, int, int)
public boolean disableCellBroadcastRange(int startMessageId, int endMessageId, int ranType)
startMessageId
- first message identifier as specified in TS 23.041 (3GPP)
or C.R1001-G (3GPP2)endMessageId
- last message identifier as specified in TS 23.041 (3GPP)
or C.R1001-G (3GPP2)ranType
- as defined in class SmsManager, the value can be one of these:
android.telephony.SmsMessage.CELL_BROADCAST_RAN_TYPE_GSM
android.telephony.SmsMessage.CELL_BROADCAST_RAN_TYPE_CDMAIllegalArgumentException
- if endMessageId < startMessageId
enableCellBroadcastRange(int, int, int)
public boolean isImsSmsSupported()
getImsSmsFormat()
public String getImsSmsFormat()
isImsSmsSupported()
public static int getDefaultSmsSubscriptionId()
public boolean isSMSPromptEnabled()
public void sendMultimediaMessage(Context context, Uri contentUri, String locationUrl, Bundle configOverrides, PendingIntent sentIntent)
context
- application contextcontentUri
- the content Uri from which the message pdu will be readlocationUrl
- the optional location url where message should be sent toconfigOverrides
- the carrier-specific messaging configuration values to override for
sending the message.sentIntent
- if not NULL this PendingIntent
is
broadcast when the message is successfully sent, or failedIllegalArgumentException
- if contentUri is emptypublic void downloadMultimediaMessage(Context context, String locationUrl, Uri contentUri, Bundle configOverrides, PendingIntent downloadedIntent)
context
- application contextlocationUrl
- the location URL of the MMS message to be downloaded, usually obtained
from the MMS WAP push notificationcontentUri
- the content uri to which the downloaded pdu will be writtenconfigOverrides
- the carrier-specific messaging configuration values to override for
downloading the message.downloadedIntent
- if not NULL this PendingIntent
is
broadcast when the message is downloaded, or the download is failedIllegalArgumentException
- if locationUrl or contentUri is emptypublic Uri importTextMessage(String address, int type, String text, long timestampMillis, boolean seen, boolean read)
address
- the destination(source) address of the sent(received) messagetype
- the type of the messagetext
- the message texttimestampMillis
- the message timestamp in millisecondsseen
- if the message is seenread
- if the message is readpublic Uri importMultimediaMessage(Uri contentUri, String messageId, long timestampSecs, boolean seen, boolean read)
contentUri
- the content uri from which to read the PDU of the message to importmessageId
- the optional message id. Use null if not specifyingtimestampSecs
- the optional message timestamp. Use -1 if not specifyingseen
- if the message is seenread
- if the message is readIllegalArgumentException
- if pdu is empty
public boolean deleteStoredMessage(Uri messageUri)
messageUri
- the URI of the stored messageIllegalArgumentException
- if messageUri is empty
public boolean deleteStoredConversation(long conversationId)
conversationId
- the ID of the message conversationpublic boolean updateStoredMessageStatus(Uri messageUri, ContentValues statusValues)
messageUri
- the URI of the stored messagestatusValues
- a list of status properties in key-value pairs to updateIllegalArgumentException
- if messageUri is empty
public boolean archiveStoredConversation(long conversationId, boolean archived)
conversationId
- the ID of the message conversationarchived
- true to archive the conversation, false to unarchivepublic Uri addTextMessageDraft(String address, String text)
address
- the destination address of messagetext
- the body of the message to sendpublic Uri addMultimediaMessageDraft(Uri contentUri)
contentUri
- the content uri from which to read the PDU data of the draft MMSIllegalArgumentException
- if pdu is empty
public void sendStoredTextMessage(Uri messageUri, String scAddress, PendingIntent sentIntent, PendingIntent deliveryIntent)
messageUri
- the URI of the stored messagescAddress
- is the service center address or null to use the current default SMSCsentIntent
- 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_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
RESULT_ERROR_GENERIC_FAILURE
the sentIntent may include
the extra "errorCode" containing a radio technology specific value,
generally only useful for troubleshooting.deliveryIntent
- 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").IllegalArgumentException
- if messageUri is empty
public void sendStoredMultipartTextMessage(Uri messageUri, String scAddress, ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents)
PendingIntent
lists should match the part number of the
divided text of the stored message by using divideMessage
messageUri
- the URI of the stored messagescAddress
- is the service center address or null to use
the current default SMSCsentIntents
- if not null, an ArrayList
of
PendingIntent
s (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_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
RESULT_ERROR_GENERIC_FAILURE
each sentIntent may include
the extra "errorCode" containing a radio technology specific value,
generally only useful for troubleshooting.deliveryIntents
- if not null, an ArrayList
of
PendingIntent
s (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").IllegalArgumentException
- if messageUri is empty
public void sendStoredMultimediaMessage(Uri messageUri, Bundle configOverrides, PendingIntent sentIntent)
messageUri
- the URI of the stored messageconfigOverrides
- the carrier-specific messaging configuration values to override for
sending the message.sentIntent
- if not NULL this PendingIntent
is
broadcast when the message is successfully sent, or failedIllegalArgumentException
- if messageUri is empty
public void setAutoPersisting(boolean enabled)
enabled
- Whether to enable message auto persisting
public boolean getAutoPersisting()
public Bundle getCarrierConfigValues()
public static Bundle getMmsConfig(BaseBundle config)
CarrierConfigManager
which contain MMS
config and unrelated config. It is assumed that all MMS_CONFIG_* keys are present in the
supplied bundle.config
- a Bundle that contains MMS config variables and possibly more.