FileDocCategorySizeDatePackage
SmsManager.javaAPI DocAndroid 5.1 API10957Thu Mar 12 22:22:54 GMT 2015android.telephony.gsm

SmsManager

public final class SmsManager extends Object
Manages SMS operations such as sending data, text, and pdu SMS messages. Get this object by calling the static method SmsManager.getDefault().
deprecated
Replaced by android.telephony.SmsManager that supports both GSM and CDMA.

Fields Summary
private static SmsManager
sInstance
private android.telephony.SmsManager
mSmsMgrProxy
public static final int
STATUS_ON_SIM_FREE
Free space (TS 51.011 10.5.3).
public static final int
STATUS_ON_SIM_READ
Received and read (TS 51.011 10.5.3).
public static final int
STATUS_ON_SIM_UNREAD
Received and unread (TS 51.011 10.5.3).
public static final int
STATUS_ON_SIM_SENT
Stored and sent (TS 51.011 10.5.3).
public static final int
STATUS_ON_SIM_UNSENT
Stored and unsent (TS 51.011 10.5.3).
public static final int
RESULT_ERROR_GENERIC_FAILURE
Generic failure cause
public static final int
RESULT_ERROR_RADIO_OFF
Failed because radio was explicitly turned off
public static final int
RESULT_ERROR_NULL_PDU
Failed because no pdu provided
public static final int
RESULT_ERROR_NO_SERVICE
Failed because service is currently unavailable
Constructors Summary
private SmsManager()

        mSmsMgrProxy = android.telephony.SmsManager.getDefault();
    
Methods Summary
public final booleancopyMessageToSim(byte[] smsc, byte[] pdu, int status)
Copy a raw SMS PDU to the SIM.

param
smsc the SMSC for this message, or NULL for the default SMSC
param
pdu the raw PDU to store
param
status message status (STATUS_ON_SIM_READ, STATUS_ON_SIM_UNREAD, STATUS_ON_SIM_SENT, STATUS_ON_SIM_UNSENT)
return
true for success
deprecated
Use android.telephony.SmsManager. {@hide}

        return mSmsMgrProxy.copyMessageToIcc(smsc, pdu, status);
    
public final booleandeleteMessageFromSim(int messageIndex)
Delete the specified message from the SIM.

param
messageIndex is the record index of the message on SIM
return
true for success
deprecated
Use android.telephony.SmsManager. {@hide}

        return mSmsMgrProxy.deleteMessageFromIcc(messageIndex);
    
public final java.util.ArrayListdivideMessage(java.lang.String text)
Divide a text message into several messages, none bigger than the maximum SMS message size.

param
text the original message. Must not be null.
return
an ArrayList of strings that, in order, comprise the original message
deprecated
Use android.telephony.SmsManager.

        return mSmsMgrProxy.divideMessage(text);
    
public final java.util.ArrayListgetAllMessagesFromSim()
Retrieves all messages currently stored on SIM.

return
ArrayList of SmsMessage objects
deprecated
Use android.telephony.SmsManager. {@hide}

        return android.telephony.SmsManager.getDefault().getAllMessagesFromIcc();
    
public static final android.telephony.gsm.SmsManagergetDefault()
Get the default instance of the SmsManager

return
the default instance of the SmsManager
deprecated
Use android.telephony.SmsManager.

        if (sInstance == null) {
            sInstance = new SmsManager();
        }
        return sInstance;
    
public final voidsendDataMessage(java.lang.String destinationAddress, java.lang.String scAddress, short destinationPort, byte[] data, android.app.PendingIntent sentIntent, android.app.PendingIntent deliveryIntent)
Send a data based SMS to a specific application port.

param
destinationAddress the address to send the message to
param
scAddress is the service center address or null to use the current default SMSC
param
destinationPort the port to deliver the message to
param
data the body of the message to send
param
sentIntent if not NULL this PendingIntent is broadcast when the message is sucessfully 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. The per-application based SMS control checks sentIntent. If sentIntent is NULL the caller will be checked against all unknown applicaitons, which cause smaller number of SMS to be sent in checking period.
param
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").
throws
IllegalArgumentException if destinationAddress or data are empty
deprecated
Use android.telephony.SmsManager.

        mSmsMgrProxy.sendDataMessage(destinationAddress, scAddress, destinationPort,
                data, sentIntent, deliveryIntent);
    
public final voidsendMultipartTextMessage(java.lang.String destinationAddress, java.lang.String scAddress, java.util.ArrayList parts, java.util.ArrayList sentIntents, java.util.ArrayList deliveryIntents)
Send a multi-part text based SMS. The callee should have already divided the message into correctly sized parts by calling divideMessage.

param
destinationAddress the address to send the message to
param
scAddress is the service center address or null to use the current default SMSC
param
parts an ArrayList of strings that, in order, comprise the original message
param
sentIntents 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_FAILURE RESULT_ERROR_RADIO_OFF RESULT_ERROR_NULL_PDU. The per-application based SMS control checks sentIntent. If sentIntent is NULL the caller will be checked against all unknown applicaitons, which cause smaller number of SMS to be sent in checking period.
param
deliveryIntents 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
deprecated
Use android.telephony.SmsManager.

        mSmsMgrProxy.sendMultipartTextMessage(destinationAddress, scAddress, parts,
                sentIntents, deliveryIntents);
    
public final voidsendTextMessage(java.lang.String destinationAddress, java.lang.String scAddress, java.lang.String text, android.app.PendingIntent sentIntent, android.app.PendingIntent deliveryIntent)
Send a text based SMS.

param
destinationAddress the address to send the message to
param
scAddress is the service center address or null to use the current default SMSC
param
text the body of the message to send
param
sentIntent 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. 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.
param
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").
throws
IllegalArgumentException if destinationAddress or text are empty
deprecated
Use android.telephony.SmsManager.

        mSmsMgrProxy.sendTextMessage(destinationAddress, scAddress, text,
                sentIntent, deliveryIntent);
    
public final booleanupdateMessageOnSim(int messageIndex, int newStatus, byte[] pdu)
Update the specified message on the SIM.

param
messageIndex record index of message to update
param
newStatus new message status (STATUS_ON_SIM_READ, STATUS_ON_SIM_UNREAD, STATUS_ON_SIM_SENT, STATUS_ON_SIM_UNSENT, STATUS_ON_SIM_FREE)
param
pdu the raw PDU to store
return
true for success
deprecated
Use android.telephony.SmsManager. {@hide}

        return mSmsMgrProxy.updateMessageOnIcc(messageIndex, newStatus, pdu);