Build 1.0_r1(from source)

android.telephony.gsm
Class SmsManager

java.lang.Object
  extended by android.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().


Field Summary
static int RESULT_ERROR_GENERIC_FAILURE
          Generic failure cause
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 STATUS_ON_SIM_FREE
          Free space (TS 51.011 10.5.3).
static int STATUS_ON_SIM_READ
          Received and read (TS 51.011 10.5.3).
static int STATUS_ON_SIM_SENT
          Stored and sent (TS 51.011 10.5.3).
static int STATUS_ON_SIM_UNREAD
          Received and unread (TS 51.011 10.5.3).
static int STATUS_ON_SIM_UNSENT
          Stored and unsent (TS 51.011 10.5.3).
 
Method Summary
 boolean copyMessageToSim(byte[] smsc, byte[] pdu, int status)
          Copy a raw SMS PDU to the SIM.
 boolean deleteMessageFromSim(int messageIndex)
          Delete the specified message from the SIM.
 ArrayList<String> divideMessage(String text)
          Divide a text message into several messages, none bigger than the maximum SMS message size.
 ArrayList<SmsMessage> getAllMessagesFromSim()
          Retrieves all messages currently stored on SIM.
static SmsManager getDefault()
          Get the default instance of the SmsManager
 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 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.
 boolean updateMessageOnSim(int messageIndex, int newStatus, byte[] pdu)
          Update the specified message on the SIM.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_ON_SIM_FREE

public static final int STATUS_ON_SIM_FREE
Free space (TS 51.011 10.5.3).

See Also:
Constant Field Values

STATUS_ON_SIM_READ

public static final int STATUS_ON_SIM_READ
Received and read (TS 51.011 10.5.3).

See Also:
Constant Field Values

STATUS_ON_SIM_UNREAD

public static final int STATUS_ON_SIM_UNREAD
Received and unread (TS 51.011 10.5.3).

See Also:
Constant Field Values

STATUS_ON_SIM_SENT

public static final int STATUS_ON_SIM_SENT
Stored and sent (TS 51.011 10.5.3).

See Also:
Constant Field Values

STATUS_ON_SIM_UNSENT

public static final int STATUS_ON_SIM_UNSENT
Stored and unsent (TS 51.011 10.5.3).

See Also:
Constant Field Values

RESULT_ERROR_GENERIC_FAILURE

public static final int RESULT_ERROR_GENERIC_FAILURE
Generic failure cause

See Also:
Constant Field Values

RESULT_ERROR_RADIO_OFF

public static final int RESULT_ERROR_RADIO_OFF
Failed because radio was explicitly turned off

See Also:
Constant Field Values

RESULT_ERROR_NULL_PDU

public static final int RESULT_ERROR_NULL_PDU
Failed because no pdu provided

See Also:
Constant Field Values

RESULT_ERROR_NO_SERVICE

public static final int RESULT_ERROR_NO_SERVICE
Failed because service is currently unavailable

See Also:
Constant Field Values
Method Detail

sendTextMessage

public void sendTextMessage(String destinationAddress,
                            String scAddress,
                            String text,
                            PendingIntent sentIntent,
                            PendingIntent deliveryIntent)
Send a text based SMS.

Parameters:
destinationAddress - the address to send the message to
scAddress - is the service center address or null to use the current default SMSC
text - the body of the message to send
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.
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

divideMessage

public ArrayList<String> divideMessage(String text)
Divide a text message into several messages, none bigger than the maximum SMS message size.

Parameters:
text - the original message. Must not be null.
Returns:
an ArrayList of strings that, in order, comprise the original message

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.

Parameters:
destinationAddress - the address to send the message to
scAddress - is the service center address or null to use the current default SMSC
parts - an ArrayList of strings that, in order, comprise the original message
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.
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").

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.

Parameters:
destinationAddress - the address to send the message to
scAddress - is the service center address or null to use the current default SMSC
destinationPort - the port to deliver the message to
data - the body of the message to send
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.
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

getDefault

public static SmsManager getDefault()
Get the default instance of the SmsManager

Returns:
the default instance of the SmsManager

copyMessageToSim

public boolean copyMessageToSim(byte[] smsc,
                                byte[] pdu,
                                int status)
Copy a raw SMS PDU to the SIM.

Parameters:
smsc - the SMSC for this message, or NULL for the default SMSC
pdu - the raw PDU to store
status - message status (STATUS_ON_SIM_READ, STATUS_ON_SIM_UNREAD, STATUS_ON_SIM_SENT, STATUS_ON_SIM_UNSENT)
Returns:
true for success

deleteMessageFromSim

public boolean deleteMessageFromSim(int messageIndex)
Delete the specified message from the SIM.

Parameters:
messageIndex - is the record index of the message on SIM
Returns:
true for success

updateMessageOnSim

public boolean updateMessageOnSim(int messageIndex,
                                  int newStatus,
                                  byte[] pdu)
Update the specified message on the SIM.

Parameters:
messageIndex - record index of message to update
newStatus - new message status (STATUS_ON_SIM_READ, STATUS_ON_SIM_UNREAD, STATUS_ON_SIM_SENT, STATUS_ON_SIM_UNSENT, STATUS_ON_SIM_FREE)
pdu - the raw PDU to store
Returns:
true for success

getAllMessagesFromSim

public ArrayList<SmsMessage> getAllMessagesFromSim()
Retrieves all messages currently stored on SIM.

Returns:
ArrayList of SmsMessage objects

Build 1.0_r1(from source)

Please submit a feedback, bug or feature