Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public class

SmsMessage

extends Object
java.lang.Object
   ↳ android.telephony.gsm.SmsMessage

This class was deprecated in API level 4.
Replaced by android.telephony.SmsMessage that supports both GSM and CDMA.

Class Overview

A Short Message Service message.

Summary

Nested Classes
enum SmsMessage.MessageClass This enum was deprecated in API level 4. Use android.telephony.SmsMessage.  
class SmsMessage.SubmitPdu This class was deprecated in API level 4. Use android.telephony.SmsMessage.  
Constants
int ENCODING_16BIT This constant was deprecated in API level 4. Use android.telephony.SmsMessage.
int ENCODING_7BIT This constant was deprecated in API level 4. Use android.telephony.SmsMessage.
int ENCODING_8BIT This constant was deprecated in API level 4. Use android.telephony.SmsMessage.
int ENCODING_UNKNOWN This constant was deprecated in API level 4. Use android.telephony.SmsMessage.
int MAX_USER_DATA_BYTES This constant was deprecated in API level 4. Use android.telephony.SmsMessage.
int MAX_USER_DATA_SEPTETS This constant was deprecated in API level 4. Use android.telephony.SmsMessage.
int MAX_USER_DATA_SEPTETS_WITH_HEADER This constant was deprecated in API level 4. Use android.telephony.SmsMessage.
Public Constructors
SmsMessage ()
This constructor was deprecated in API level 4. Use android.telephony.SmsMessage.
Public Methods
static int[] calculateLength ( CharSequence messageBody, boolean use7bitOnly)
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
static int[] calculateLength ( String messageBody, boolean use7bitOnly)
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
static SmsMessage createFromPdu (byte[] pdu)
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
String getDisplayMessageBody ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
String getDisplayOriginatingAddress ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
String getEmailBody ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
String getEmailFrom ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
int getIndexOnSim ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage and getIndexOnIcc instead.
String getMessageBody ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
SmsMessage.MessageClass getMessageClass ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
String getOriginatingAddress ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
byte[] getPdu ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
int getProtocolIdentifier ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
String getPseudoSubject ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
String getServiceCenterAddress ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
int getStatus ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
int getStatusOnSim ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage and getStatusOnIcc instead.
static SmsMessage.SubmitPdu getSubmitPdu ( String scAddress, String destinationAddress, short destinationPort, byte[] data, boolean statusReportRequested)
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
static SmsMessage.SubmitPdu getSubmitPdu ( String scAddress, String destinationAddress, String message, boolean statusReportRequested)
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
static int getTPLayerLengthForPDU ( String pdu)
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
long getTimestampMillis ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
byte[] getUserData ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
boolean isCphsMwiMessage ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
boolean isEmail ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
boolean isMWIClearMessage ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
boolean isMWISetMessage ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
boolean isMwiDontStore ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
boolean isReplace ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
boolean isReplyPathPresent ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
boolean isStatusReportMessage ()
This method was deprecated in API level 4. Use android.telephony.SmsMessage.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int ENCODING_16BIT

Added in API level 1

This constant was deprecated in API level 4.
Use android.telephony.SmsMessage.

16-bit encoding scheme (see TS 23.038)

Constant Value: 3 (0x00000003)

public static final int ENCODING_7BIT

Added in API level 1

This constant was deprecated in API level 4.
Use android.telephony.SmsMessage.

7-bit encoding scheme (see TS 23.038)

Constant Value: 1 (0x00000001)

public static final int ENCODING_8BIT

Added in API level 1

This constant was deprecated in API level 4.
Use android.telephony.SmsMessage.

8-bit encoding scheme (see TS 23.038)

Constant Value: 2 (0x00000002)

public static final int ENCODING_UNKNOWN

Added in API level 1

This constant was deprecated in API level 4.
Use android.telephony.SmsMessage.

Unknown encoding scheme (see TS 23.038)

Constant Value: 0 (0x00000000)

public static final int MAX_USER_DATA_BYTES

Added in API level 1

This constant was deprecated in API level 4.
Use android.telephony.SmsMessage.

The maximum number of payload bytes per message

Constant Value: 140 (0x0000008c)

public static final int MAX_USER_DATA_SEPTETS

Added in API level 1

This constant was deprecated in API level 4.
Use android.telephony.SmsMessage.

The maximum number of payload septets per message

Constant Value: 160 (0x000000a0)

public static final int MAX_USER_DATA_SEPTETS_WITH_HEADER

Added in API level 1

This constant was deprecated in API level 4.
Use android.telephony.SmsMessage.

The maximum number of payload septets per message if a user data header is present. This assumes the header only contains the CONCATENATED_8_BIT_REFERENCE element.

Constant Value: 153 (0x00000099)

Public Constructors

public SmsMessage ()

Added in API level 1

This constructor was deprecated in API level 4.
Use android.telephony.SmsMessage.

Public Methods

public static int[] calculateLength ( CharSequence messageBody, boolean use7bitOnly)

Added in API level 3

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Calculates the number of SMS's required to encode the message body and the number of characters remaining until the next message, given the current encoding.

Parameters
messageBody the message to encode
use7bitOnly if true, characters that are not part of the GSM alphabet are counted as a single space char. If false, a messageBody containing non-GSM alphabet characters is calculated for 16-bit encoding.
Returns
  • an int[4] with int[0] being the number of SMS's required, int[1] the number of code units used, and int[2] is the number of code units remaining until the next message. int[3] is the encoding type that should be used for the message.

public static int[] calculateLength ( String messageBody, boolean use7bitOnly)

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Calculates the number of SMS's required to encode the message body and the number of characters remaining until the next message, given the current encoding.

Parameters
messageBody the message to encode
use7bitOnly if true, characters that are not part of the GSM alphabet are counted as a single space char. If false, a messageBody containing non-GSM alphabet characters is calculated for 16-bit encoding.
Returns
  • an int[4] with int[0] being the number of SMS's required, int[1] the number of code units used, and int[2] is the number of code units remaining until the next message. int[3] is the encoding type that should be used for the message.

public static SmsMessage createFromPdu (byte[] pdu)

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Create an SmsMessage from a raw PDU.

public String getDisplayMessageBody ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Returns the message body, or email message body if this message was from an email gateway. Returns null if message body unavailable.

public String getDisplayOriginatingAddress ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Returns the originating address, or email from address if this message was from an email gateway. Returns null if originating address unavailable.

public String getEmailBody ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Returns
  • if isEmail() is true, body of the email sent through the gateway. null otherwise

public String getEmailFrom ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Returns
  • if isEmail() is true, email from address of email sent through the gateway. null otherwise

public int getIndexOnSim ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage and getIndexOnIcc instead.

Returns the record index of the message on the SIM (1-based index).

Returns
  • the record index of the message on the SIM, or -1 if this SmsMessage was not created from a SIM SMS EF record.

public String getMessageBody ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Returns the message body as a String, if it exists and is text based.

Returns
  • message body is there is one, otherwise null

public SmsMessage.MessageClass getMessageClass ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Returns the class of this message.

public String getOriginatingAddress ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Returns the originating address (sender) of this SMS message in String form or null if unavailable

public byte[] getPdu ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Returns the raw PDU for the message.

Returns
  • the raw PDU for the message.

public int getProtocolIdentifier ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Get protocol identifier.

public String getPseudoSubject ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Unofficial convention of a subject line enclosed in parens empty string if not present

public String getServiceCenterAddress ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Returns the address of the SMS service center that relayed this message or null if there is none.

public int getStatus ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

GSM: For an SMS-STATUS-REPORT message, this returns the status field from the status report. This field indicates the status of a previously submitted SMS, if requested. See TS 23.040, 9.2.3.15 TP-Status for a description of values. CDMA: For not interfering with status codes from GSM, the value is shifted to the bits 31-16. The value is composed of an error class (bits 25-24) and a status code (bits 23-16). Possible codes are described in C.S0015-B, v2.0, 4.5.21.

Returns
  • 0 indicates the previously sent message was received. See TS 23.040, 9.9.2.3.15 and C.S0015-B, v2.0, 4.5.21 for a description of other possible values.

public int getStatusOnSim ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage and getStatusOnIcc instead.

Returns the status of the message on the SIM (read, unread, sent, unsent).

Returns
  • the status of the message on the SIM. These are: SmsManager.STATUS_ON_SIM_FREE SmsManager.STATUS_ON_SIM_READ SmsManager.STATUS_ON_SIM_UNREAD SmsManager.STATUS_ON_SIM_SEND SmsManager.STATUS_ON_SIM_UNSENT

public static SmsMessage.SubmitPdu getSubmitPdu ( String scAddress, String destinationAddress, short destinationPort, byte[] data, boolean statusReportRequested)

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Get an SMS-SUBMIT PDU for a data message to a destination address & port

Parameters
scAddress Service Centre address. null == use default
destinationAddress the address of the destination for the message
destinationPort the port to deliver the message to at the destination
data the dat for the message
Returns
  • a SubmitPdu containing the encoded SC address, if applicable, and the encoded message. Returns null on encode error.

public static SmsMessage.SubmitPdu getSubmitPdu ( String scAddress, String destinationAddress, String message, boolean statusReportRequested)

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Get an SMS-SUBMIT PDU for a destination address and a message

Parameters
scAddress Service Centre address. Null means use default.
Returns
  • a SubmitPdu containing the encoded SC address, if applicable, and the encoded message. Returns null on encode error.

public static int getTPLayerLengthForPDU ( String pdu)

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Get the TP-Layer-Length for the given SMS-SUBMIT PDU Basically, the length in bytes (not hex chars) less the SMSC header

public long getTimestampMillis ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Returns the service centre timestamp in currentTimeMillis() format

public byte[] getUserData ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

returns the user data section minus the user data header if one was present.

public boolean isCphsMwiMessage ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Returns true for CPHS MWI toggle message.

Returns
  • true if this is a CPHS MWI toggle message See CPHS 4.2 section B.4.2

public boolean isEmail ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Returns true if message is an email.

Returns
  • true if this message came through an email gateway and email sender / subject / parsed body are available

public boolean isMWIClearMessage ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

returns true if this message is a CPHS voicemail / message waiting indicator (MWI) clear message

public boolean isMWISetMessage ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

returns true if this message is a CPHS voicemail / message waiting indicator (MWI) set message

public boolean isMwiDontStore ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

returns true if this message is a "Message Waiting Indication Group: Discard Message" notification and should not be stored.

public boolean isReplace ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

See TS 23.040 9.2.3.9 returns true if this is a "replace short message" SMS

public boolean isReplyPathPresent ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Returns true iff the TP-Reply-Path bit is set in this message.

public boolean isStatusReportMessage ()

Added in API level 1

This method was deprecated in API level 4.
Use android.telephony.SmsMessage.

Return true iff the message is a SMS-STATUS-REPORT message.