English | Site Directory

Android - An Open Handset Alliance Project

android.telephony.gsm
public class

android.telephony.gsm.SmsMessage

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

A Short Message Service message.

Nested Classes

Summary

Constants

      Value  
int  ENCODING_16BIT  16-bit encoding scheme (see TS 23.038)   0x00000003 
int  ENCODING_7BIT  7-bit encoding scheme (see TS 23.038)   0x00000001 
int  ENCODING_8BIT  8-bit encoding scheme (see TS 23.038)   0x00000002 
int  ENCODING_UNKNOWN  Unknown encoding scheme (see TS 23.038)   0x00000000 
int  MAX_USER_DATA_BYTES  The maximum number of payload bytes per message   140  0x0000008c 
int  MAX_USER_DATA_SEPTETS  The maximum number of payload septets per message   160  0x000000a0 
int  SMS_STATUS_REPORT_MASK_PERMANENT_ERROR    64  0x00000040 
int  SMS_STATUS_REPORT_MASK_TEMPORARY_ERROR  masks for some ranges of values for the SMS-STATUS-REPORT field   32  0x00000020 
int  SMS_STATUS_REPORT_NOT_RECEIVED  some possible values for the SMS-STATUS-REPORT field, plus -1 to represent that it hasn't yet been received   -1  0xffffffff 
int  SMS_STATUS_REPORT_SME_UNABLE_TO_CONFIRM    0x00000001 
int  SMS_STATUS_REPORT_SMS_REPLACED_BY_SC    0x00000002 
int  SMS_STATUS_REPORT_SUCCESS    0x00000000 

Public Constructors

          SmsMessage()

Public Methods

      static  int[]  calculateLength(String messageBody)
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.
      static  SmsMessage  createFromPdu(byte[] pdu)
Create an SmsMessage from a raw PDU.
        String  getDisplayMessageBody()
Returns the message body, or email message body if this message was from an email gateway.
        String  getDisplayOriginatingAddress()
Returns the originating address, or email from address if this message was from an email gateway.
        String  getEmailBody()
        String  getEmailFrom()
        int  getIndexOnSim()
Returns the record index of the message on the SIM (1-based index).
        String  getMessageBody()
Returns the message body as a String, if it exists and is text based.
        MessageClass  getMessageClass()
Returns the class of this message.
        String  getOriginatingAddress()
Returns the originating address (sender) of this SMS message in String form or null if unavailable
        byte[]  getPdu()
Returns the raw PDU for the message.
        String  getPseudoSubject()
Unofficial convention of a subject line enclosed in parens empty string if not present
        String  getServiceCenterAddress()
Returns the address of the SMS service center that relayed this message or null if there is none.
        int  getStatus()
For an SMS-STATUS-REPORT message, this returns the status field from the status report.
        int  getStatusOnSim()
Returns the status of the message on the SIM (read, unread, sent, unsent).
      static  SubmitPdu  getSubmitPdu(String scAddress, String destinationAddress, short destinationPort, byte[] data, boolean statusReportRequested)
Get an SMS-SUBMIT PDU for a data message to a destination address & port
      static  SubmitPdu  getSubmitPdu(String scAddress, String destinationAddress, String message, boolean statusReportRequested)
Get an SMS-SUBMIT PDU for a destination address and a message
      static  int  getTPLayerLengthForPDU(String pdu)
Get the TP-Layer-Length for the given SMS-SUBMIT PDU Basically, the length in bytes (not hex chars) less the SMSC header
        long  getTimestampMillis()
Returns the service centre timestamp in currentTimeMillis() format
        byte[]  getUserData()
returns the user data section minus the user data header if one was present.
        SmsHeader  getUserDataHeader()
Returns an object representing the user data header
        boolean  isCphsMwiMessage()
Returns true for CPHS MWI toggle message.
        boolean  isEmail()
Returns true if message is an email.
        boolean  isMWIClearMessage()
returns true if this message is a CPHS voicemail / message waiting indicator (MWI) clear message
        boolean  isMWISetMessage()
returns true if this message is a CPHS voicemail / message waiting indicator (MWI) set message
        boolean  isMwiDontStore()
returns true if this message is a "Message Waiting Indication Group: Discard Message" notification and should not be stored.
        boolean  isReplace()
See TS 23.040 9.2.3.9 returns true if this is a "replace short message" SMS
        boolean  isReplyPathPresent()
Returns true iff the TP-Reply-Path bit is set in this message.
      static  boolean  isStatusPermanentError(int status)
For an SMS-STATUS-REPORT message, return true iff the status field indicates that there has been a permanent error delivering the message.
      static  boolean  isStatusReceived(int status)
For an SMS-STATUS-REPORT message, return true iff the status field indicates that the message status has been received.
        boolean  isStatusReportMessage()
Return true iff the message is a SMS-STATUS-REPORT message.
      static  boolean  isStatusSuccessful(int status)
For an SMS-STATUS-REPORT message, return true iff the status field indicates that the message was delivered successfully.
      static  boolean  isStatusTemporaryError(int status)
For an SMS-STATUS-REPORT message, return true iff the status field indicates that there has been a temporary error delivering the message.
Methods inherited from class java.lang.Object

Details

Constants

public static final int ENCODING_16BIT

16-bit encoding scheme (see TS 23.038)
Constant Value: 3 (0x00000003)

public static final int ENCODING_7BIT

7-bit encoding scheme (see TS 23.038)
Constant Value: 1 (0x00000001)

public static final int ENCODING_8BIT

8-bit encoding scheme (see TS 23.038)
Constant Value: 2 (0x00000002)

public static final int ENCODING_UNKNOWN

Unknown encoding scheme (see TS 23.038)
Constant Value: 0 (0x00000000)

public static final int MAX_USER_DATA_BYTES

The maximum number of payload bytes per message
Constant Value: 140 (0x0000008c)

public static final int MAX_USER_DATA_SEPTETS

The maximum number of payload septets per message
Constant Value: 160 (0x000000a0)

public static final int SMS_STATUS_REPORT_MASK_PERMANENT_ERROR

Constant Value: 64 (0x00000040)

public static final int SMS_STATUS_REPORT_MASK_TEMPORARY_ERROR

masks for some ranges of values for the SMS-STATUS-REPORT field
Constant Value: 32 (0x00000020)

public static final int SMS_STATUS_REPORT_NOT_RECEIVED

some possible values for the SMS-STATUS-REPORT field, plus -1 to represent that it hasn't yet been received
Constant Value: -1 (0xffffffff)

public static final int SMS_STATUS_REPORT_SME_UNABLE_TO_CONFIRM

Constant Value: 1 (0x00000001)

public static final int SMS_STATUS_REPORT_SMS_REPLACED_BY_SC

Constant Value: 2 (0x00000002)

public static final int SMS_STATUS_REPORT_SUCCESS

Constant Value: 0 (0x00000000)

Public Constructors

public SmsMessage()

Public Methods

public static int[] calculateLength(String messageBody)

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.

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] os the encoding type that should be used for the message.

public static SmsMessage createFromPdu(byte[] pdu)

Create an SmsMessage from a raw PDU.

public String getDisplayMessageBody()

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()

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()

Returns

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

public String getEmailFrom()

Returns

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

public int getIndexOnSim()

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()

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

Returns

  • message body is there is one, otherwise null

public MessageClass getMessageClass()

Returns the class of this message.

public String getOriginatingAddress()

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

public byte[] getPdu()

Returns the raw PDU for the message.

Returns

  • the raw PDU for the message.

public String getPseudoSubject()

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

public String getServiceCenterAddress()

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

public int getStatus()

For an SMS-STATUS-REPORT message, this returns the status field from the status report. This field indicates the status of a previousely submitted SMS, if requested. See TS 23.040, 9.2.3.15 TP-Status for a description of values.

Returns

  • 0 indicates the previously sent message was received. See TS 23.040, 9.9.2.3.15 for a description of other possible values.

public int getStatusOnSim()

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 SubmitPdu getSubmitPdu(String scAddress, String destinationAddress, short destinationPort, byte[] data, boolean statusReportRequested)

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 SubmitPdu getSubmitPdu(String scAddress, String destinationAddress, String message, boolean statusReportRequested)

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)

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()

Returns the service centre timestamp in currentTimeMillis() format

public byte[] getUserData()

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

public SmsHeader getUserDataHeader()

Returns an object representing the user data header

Returns

  • an object representing the user data header

public boolean isCphsMwiMessage()

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()

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()

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

public boolean isMWISetMessage()

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

public boolean isMwiDontStore()

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

public boolean isReplace()

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

public boolean isReplyPathPresent()

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

public static boolean isStatusPermanentError(int status)

For an SMS-STATUS-REPORT message, return true iff the status field indicates that there has been a permanent error delivering the message.

public static boolean isStatusReceived(int status)

For an SMS-STATUS-REPORT message, return true iff the status field indicates that the message status has been received.

public boolean isStatusReportMessage()

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

public static boolean isStatusSuccessful(int status)

For an SMS-STATUS-REPORT message, return true iff the status field indicates that the message was delivered successfully.

public static boolean isStatusTemporaryError(int status)

For an SMS-STATUS-REPORT message, return true iff the status field indicates that there has been a temporary error delivering the message.
Build m5-rc15g - 14 May 2008 12:50