FileDocCategorySizeDatePackage
SmsMessage.javaAPI DocAndroid 5.1 API22005Thu Mar 12 22:22:54 GMT 2015android.telephony.gsm

SmsMessage

public class SmsMessage extends Object
A Short Message Service message.
deprecated
Replaced by android.telephony.SmsMessage that supports both GSM and CDMA.

Fields Summary
public static final int
ENCODING_UNKNOWN
Unknown encoding scheme (see TS 23.038)
public static final int
ENCODING_7BIT
7-bit encoding scheme (see TS 23.038)
public static final int
ENCODING_8BIT
8-bit encoding scheme (see TS 23.038)
public static final int
ENCODING_16BIT
16-bit encoding scheme (see TS 23.038)
public static final int
MAX_USER_DATA_BYTES
The maximum number of payload bytes per message
public static final int
MAX_USER_DATA_BYTES_WITH_HEADER
The maximum number of payload bytes per message if a user data header is present. This assumes the header only contains the CONCATENATED_8_BIT_REFERENCE element.
public static final int
MAX_USER_DATA_SEPTETS
The maximum number of payload septets per message
public static final int
MAX_USER_DATA_SEPTETS_WITH_HEADER
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.
public com.android.internal.telephony.SmsMessageBase
mWrappedSmsMessage
Contains actual SmsMessage. Only public for debugging and for framework layer.
Constructors Summary
public SmsMessage()

deprecated
Use android.telephony.SmsMessage.

        this(getSmsFacility());
    
private SmsMessage(com.android.internal.telephony.SmsMessageBase smb)

        mWrappedSmsMessage = smb;
    
Methods Summary
public static int[]calculateLength(java.lang.CharSequence messageBody, boolean use7bitOnly)
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.

param
messageBody the message to encode
param
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.
return
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.
deprecated
Use android.telephony.SmsMessage.

        GsmAlphabet.TextEncodingDetails ted =
                com.android.internal.telephony.gsm.SmsMessage
                        .calculateLength(messageBody, use7bitOnly);
        int ret[] = new int[4];
        ret[0] = ted.msgCount;
        ret[1] = ted.codeUnitCount;
        ret[2] = ted.codeUnitsRemaining;
        ret[3] = ted.codeUnitSize;
        return ret;
    
public static int[]calculateLength(java.lang.String messageBody, boolean use7bitOnly)
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.

param
messageBody the message to encode
param
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.
return
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.
deprecated
Use android.telephony.SmsMessage.

        return calculateLength((CharSequence)messageBody, use7bitOnly);
    
public static android.telephony.gsm.SmsMessagecreateFromPdu(byte[] pdu)
Create an SmsMessage from a raw PDU.

deprecated
Use android.telephony.SmsMessage.

        SmsMessageBase wrappedMessage;
        int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();

        if (PHONE_TYPE_CDMA == activePhone) {
            wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromPdu(pdu);
        } else {
            wrappedMessage = com.android.internal.telephony.gsm.SmsMessage.createFromPdu(pdu);
        }

        return new SmsMessage(wrappedMessage);
    
public java.lang.StringgetDisplayMessageBody()
Returns the message body, or email message body if this message was from an email gateway. Returns null if message body unavailable.

deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.getDisplayMessageBody();
    
public java.lang.StringgetDisplayOriginatingAddress()
Returns the originating address, or email from address if this message was from an email gateway. Returns null if originating address unavailable.

deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.getDisplayOriginatingAddress();
    
public java.lang.StringgetEmailBody()

return
if isEmail() is true, body of the email sent through the gateway. null otherwise
deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.getEmailBody();
    
public java.lang.StringgetEmailFrom()

return
if isEmail() is true, email from address of email sent through the gateway. null otherwise
deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.getEmailFrom();
    
public intgetIndexOnIcc()
Returns the record index of the message on the ICC (1-based index).

return
the record index of the message on the ICC, or -1 if this SmsMessage was not created from a ICC SMS EF record.
deprecated
Use android.telephony.SmsMessage.
hide


        return mWrappedSmsMessage.getIndexOnIcc();
    
public intgetIndexOnSim()
Returns the record index of the message on the SIM (1-based index).

return
the record index of the message on the SIM, or -1 if this SmsMessage was not created from a SIM SMS EF record.
deprecated
Use android.telephony.SmsMessage and getIndexOnIcc instead.

        return mWrappedSmsMessage.getIndexOnIcc();
    
public java.lang.StringgetMessageBody()
Returns the message body as a String, if it exists and is text based.

return
message body is there is one, otherwise null
deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.getMessageBody();
    
public android.telephony.gsm.SmsMessage$MessageClassgetMessageClass()
Returns the class of this message.

deprecated
Use android.telephony.SmsMessage.

        int index = mWrappedSmsMessage.getMessageClass().ordinal();

        return MessageClass.values()[index];
    
public java.lang.StringgetOriginatingAddress()
Returns the originating address (sender) of this SMS message in String form or null if unavailable

deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.getOriginatingAddress();
    
public byte[]getPdu()
Returns the raw PDU for the message.

return
the raw PDU for the message.
deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.getPdu();
    
public intgetProtocolIdentifier()
Get protocol identifier.

deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.getProtocolIdentifier();
    
public java.lang.StringgetPseudoSubject()
Unofficial convention of a subject line enclosed in parens empty string if not present

deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.getPseudoSubject();
    
public java.lang.StringgetServiceCenterAddress()
Returns the address of the SMS service center that relayed this message or null if there is none.

deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.getServiceCenterAddress();
    
private static final com.android.internal.telephony.SmsMessageBasegetSmsFacility()
This method returns the reference to a specific SmsMessage object, which is used for accessing its static methods.

return
Specific SmsMessage.
deprecated
Use android.telephony.SmsMessage.

        int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
        if (PHONE_TYPE_CDMA == activePhone) {
            return new com.android.internal.telephony.cdma.SmsMessage();
        } else {
            return new com.android.internal.telephony.gsm.SmsMessage();
        }
    
public intgetStatus()
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.

return
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.
deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.getStatus();
    
public intgetStatusOnIcc()
Returns the status of the message on the ICC (read, unread, sent, unsent).

return
the status of the message on the ICC. These are: SmsManager.STATUS_ON_ICC_FREE SmsManager.STATUS_ON_ICC_READ SmsManager.STATUS_ON_ICC_UNREAD SmsManager.STATUS_ON_ICC_SEND SmsManager.STATUS_ON_ICC_UNSENT
deprecated
Use android.telephony.SmsMessage.
hide


        return mWrappedSmsMessage.getStatusOnIcc();
    
public intgetStatusOnSim()
Returns the status of the message on the SIM (read, unread, sent, unsent).

return
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
deprecated
Use android.telephony.SmsMessage and getStatusOnIcc instead.

        return mWrappedSmsMessage.getStatusOnIcc();
    
public static android.telephony.gsm.SmsMessage$SubmitPdugetSubmitPdu(java.lang.String scAddress, java.lang.String destinationAddress, java.lang.String message, boolean statusReportRequested, byte[] header)
Get an SMS-SUBMIT PDU for a destination address and a message

param
scAddress Service Centre address. Null means use default.
return
a SubmitPdu containing the encoded SC address, if applicable, and the encoded message. Returns null on encode error.
deprecated
Use android.telephony.SmsMessage.
hide

        SubmitPduBase spb;
        int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();

        if (PHONE_TYPE_CDMA == activePhone) {
            spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
                    destinationAddress, message, statusReportRequested,
                    SmsHeader.fromByteArray(header));
        } else {
            spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress,
                    destinationAddress, message, statusReportRequested, header);
        }

        return new SubmitPdu(spb);
    
public static android.telephony.gsm.SmsMessage$SubmitPdugetSubmitPdu(java.lang.String scAddress, java.lang.String destinationAddress, java.lang.String message, boolean statusReportRequested)
Get an SMS-SUBMIT PDU for a destination address and a message

param
scAddress Service Centre address. Null means use default.
return
a SubmitPdu containing the encoded SC address, if applicable, and the encoded message. Returns null on encode error.
deprecated
Use android.telephony.SmsMessage.

        SubmitPduBase spb;
        int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();

        if (PHONE_TYPE_CDMA == activePhone) {
            spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
                    destinationAddress, message, statusReportRequested, null);
        } else {
            spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress,
                    destinationAddress, message, statusReportRequested);
        }

        return new SubmitPdu(spb);
    
public static android.telephony.gsm.SmsMessage$SubmitPdugetSubmitPdu(java.lang.String scAddress, java.lang.String destinationAddress, short destinationPort, byte[] data, boolean statusReportRequested)
Get an SMS-SUBMIT PDU for a data message to a destination address & port

param
scAddress Service Centre address. null == use default
param
destinationAddress the address of the destination for the message
param
destinationPort the port to deliver the message to at the destination
param
data the dat for the message
return
a SubmitPdu containing the encoded SC address, if applicable, and the encoded message. Returns null on encode error.
deprecated
Use android.telephony.SmsMessage.

        SubmitPduBase spb;
        int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();

        if (PHONE_TYPE_CDMA == activePhone) {
            spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
                    destinationAddress, destinationPort, data, statusReportRequested);
        } else {
            spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress,
                    destinationAddress, destinationPort, data, statusReportRequested);
        }

        return new SubmitPdu(spb);
    
public static intgetTPLayerLengthForPDU(java.lang.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

deprecated
Use android.telephony.SmsMessage.

        int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();

        if (PHONE_TYPE_CDMA == activePhone) {
            return com.android.internal.telephony.cdma.SmsMessage.getTPLayerLengthForPDU(pdu);
        } else {
            return com.android.internal.telephony.gsm.SmsMessage.getTPLayerLengthForPDU(pdu);
        }
    
public longgetTimestampMillis()
Returns the service centre timestamp in currentTimeMillis() format

deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.getTimestampMillis();
    
public byte[]getUserData()
returns the user data section minus the user data header if one was present.

deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.getUserData();
    
public booleanisCphsMwiMessage()
Returns true for CPHS MWI toggle message.

return
true if this is a CPHS MWI toggle message See CPHS 4.2 section B.4.2
deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.isCphsMwiMessage();
    
public booleanisEmail()
Returns true if message is an email.

return
true if this message came through an email gateway and email sender / subject / parsed body are available
deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.isEmail();
    
public booleanisMWIClearMessage()
returns true if this message is a CPHS voicemail / message waiting indicator (MWI) clear message

deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.isMWIClearMessage();
    
public booleanisMWISetMessage()
returns true if this message is a CPHS voicemail / message waiting indicator (MWI) set message

deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.isMWISetMessage();
    
public booleanisMwiDontStore()
returns true if this message is a "Message Waiting Indication Group: Discard Message" notification and should not be stored.

deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.isMwiDontStore();
    
public booleanisReplace()
See TS 23.040 9.2.3.9 returns true if this is a "replace short message" SMS

deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.isReplace();
    
public booleanisReplyPathPresent()
Returns true iff the TP-Reply-Path bit is set in this message.

deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.isReplyPathPresent();
    
public booleanisStatusReportMessage()
Return true iff the message is a SMS-STATUS-REPORT message.

deprecated
Use android.telephony.SmsMessage.

        return mWrappedSmsMessage.isStatusReportMessage();