English | Site Directory

Android - An Open Handset Alliance Project

android.telephony.gsm
public final class

android.telephony.gsm.SmsManager

java.lang.Object
android.telephony.gsm.SmsManager

Manages SMS operations such as sending data, text, and pdu SMS messages. Get this object by calling the static method SmsManager.getDefault().

Summary

Constants

      Value  
int  ERROR_GENERIC_FAILURE  Generic failure cause   0x00000001 
int  ERROR_NULL_PDU  Failed because no pdu provided   0x00000003 
int  ERROR_RADIO_OFF  Failed because radio was explicitly turned off   0x00000002 
int  STATUS_ON_SIM_FREE  Free space (TS 51.011 10.5.3).  0x00000000 
int  STATUS_ON_SIM_READ  Received and read (TS 51.011 10.5.3).  0x00000001 
int  STATUS_ON_SIM_SENT  Stored and sent (TS 51.011 10.5.3).  0x00000005 
int  STATUS_ON_SIM_UNREAD  Received and unread (TS 51.011 10.5.3).  0x00000003 
int  STATUS_ON_SIM_UNSENT  Stored and unsent (TS 51.011 10.5.3).  0x00000007 

Public Methods

        ArrayList  divideMessage(String text)
Divide a text message into several messages, none bigger than the maximum SMS message size.
      static  SmsManager  getDefault()
Get the default instance of the SmsManager
        void  sendDataMessage(String destinationAddress, String scAddress, short destinationPort, byte[] data, Intent sentIntent, Intent deliveryIntent, Intent failedIntent)
Send a data based SMS to a specific application port.
        void  sendTextMessage(String destinationAddress, String scAddress, String text, Intent sentIntent, Intent deliveryIntent, Intent failedIntent)
Send a text based SMS.
Methods inherited from class java.lang.Object

Details

Constants

public static final int ERROR_GENERIC_FAILURE

Generic failure cause
Constant Value: 1 (0x00000001)

public static final int ERROR_NULL_PDU

Failed because no pdu provided
Constant Value: 3 (0x00000003)

public static final int ERROR_RADIO_OFF

Failed because radio was explicitly turned off
Constant Value: 2 (0x00000002)

public static final int STATUS_ON_SIM_FREE

Free space (TS 51.011 10.5.3).
Constant Value: 0 (0x00000000)

public static final int STATUS_ON_SIM_READ

Received and read (TS 51.011 10.5.3).
Constant Value: 1 (0x00000001)

public static final int STATUS_ON_SIM_SENT

Stored and sent (TS 51.011 10.5.3).
Constant Value: 5 (0x00000005)

public static final int STATUS_ON_SIM_UNREAD

Received and unread (TS 51.011 10.5.3).
Constant Value: 3 (0x00000003)

public static final int STATUS_ON_SIM_UNSENT

Stored and unsent (TS 51.011 10.5.3).
Constant Value: 7 (0x00000007)

Public Methods

public ArrayList 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

public static SmsManager getDefault()

Get the default instance of the SmsManager

Returns

  • the default instance of the SmsManager

public void sendDataMessage(String destinationAddress, String scAddress, short destinationPort, byte[] data, Intent sentIntent, Intent deliveryIntent, Intent failedIntent)

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 Intent is broadcast when the message is sucessfully sent
deliveryIntent if not NULL this Intent is broadcast when the message is delivered to the recipient. The raw pdu of the status report is in the extended data ("pdu").
failedIntent if not NULL this Intent is broadcast to indicate send failure. Error cause is in the extended data ("error"), and will be either ERROR_GENERIC_FAILURE or ERROR_RADIO_OFF.

Throws

IllegalArgumentException if destinationAddress or data are empty

public void sendTextMessage(String destinationAddress, String scAddress, String text, Intent sentIntent, Intent deliveryIntent, Intent failedIntent)

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 Intent is broadcast when the message is sucessfully sent
deliveryIntent if not NULL this Intent is broadcast when the message is delivered to the recipient. The raw pdu of the status report is in the extended data ("pdu").
failedIntent if not NULL this Intent is broadcast to indicate send failure. Error cause is in the extended data ("error"), and will be either ERROR_GENERIC_FAILURE or ERROR_RADIO_OFF.

Throws

IllegalArgumentException if destinationAddress or text are empty
Build m5-rc15f - 23 Apr 2008 12:29