public class SmsMessage extends Object
Modifier and Type | Class and Description |
---|---|
static class |
SmsMessage.MessageClass
SMS Class enumeration.
|
static class |
SmsMessage.SubmitPdu |
Modifier and Type | Field and Description |
---|---|
static int |
ENCODING_16BIT |
static int |
ENCODING_7BIT |
static int |
ENCODING_8BIT |
static int |
ENCODING_KSC5601 |
static int |
ENCODING_UNKNOWN
User data text encoding code unit size
|
static String |
FORMAT_3GPP
Indicates a 3GPP format SMS message.
|
static String |
FORMAT_3GPP2
Indicates a 3GPP2 format SMS message.
|
static int |
MAX_USER_DATA_BYTES
The maximum number of payload bytes per message
|
static int |
MAX_USER_DATA_BYTES_WITH_HEADER
The maximum number of payload bytes per message if a user data header
is present.
|
static int |
MAX_USER_DATA_SEPTETS
The maximum number of payload septets per message
|
static int |
MAX_USER_DATA_SEPTETS_WITH_HEADER
The maximum number of payload septets per message if a user data header
is present.
|
SmsMessageBase |
mWrappedSmsMessage
Contains actual SmsMessage.
|
Modifier and Type | Method and Description |
---|---|
static int[] |
calculateLength(CharSequence msgBody,
boolean use7bitOnly)
Calculates the number of SMS's required to encode the message body and
the number of characters remaining until the next message.
|
static int[] |
calculateLength(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.
|
static SmsMessage |
createFromEfRecord(int index,
byte[] data)
Create an SmsMessage from an SMS EF record.
|
static SmsMessage |
createFromPdu(byte[] pdu)
Deprecated.
Use
createFromPdu(byte[], String) instead. |
static SmsMessage |
createFromPdu(byte[] pdu,
String format)
Create an SmsMessage from a raw PDU with the specified message format.
|
static ArrayList<String> |
fragmentText(String text)
Divide a message text into several fragments, none bigger than
the maximum SMS message text size.
|
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 |
getIndexOnIcc()
Returns the record index of the message on the ICC (1-based index).
|
int |
getIndexOnSim()
Deprecated.
Use getIndexOnIcc instead.
|
String |
getMessageBody()
Returns the message body as a String, if it exists and is text based.
|
SmsMessage.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.
|
int |
getProtocolIdentifier()
Get protocol identifier.
|
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()
GSM:
For an SMS-STATUS-REPORT message, this returns the status field from
the status report.
|
int |
getStatusOnIcc()
Returns the status of the message on the ICC (read, unread, sent, unsent).
|
int |
getStatusOnSim()
Deprecated.
Use getStatusOnIcc instead.
|
int |
getSubId()
get Subscription information
|
static SmsMessage.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 SmsMessage.SubmitPdu |
getSubmitPdu(String scAddress,
String destinationAddress,
String message,
boolean statusReportRequested)
Get an SMS-SUBMIT PDU for a destination address and a message.
|
long |
getTimestampMillis()
Returns the service centre timestamp in currentTimeMillis() format
|
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
FIXME: This method is only used by a CTS test case that isn't run on CDMA devices.
|
byte[] |
getUserData()
returns the user data section minus the user data header if one was
present.
|
static boolean |
hasEmsSupport()
Decide if the carrier supports long SMS.
|
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 |
isMwiDontStore()
returns true if this message is a "Message Waiting Indication Group:
Discard Message" notification and should not be stored.
|
boolean |
isMWISetMessage()
returns true if this message is a CPHS voicemail / message waiting
indicator (MWI) set message
|
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. |
boolean |
isStatusReportMessage()
Return true iff the message is a SMS-STATUS-REPORT message.
|
static SmsMessage |
newFromCMT(String[] lines)
TS 27.005 3.4.1 lines[0] and lines[1] are the two lines read from the
+CMT unsolicited response (PDU mode, of course)
+CMT: [<alpha>],
|
static SmsMessage |
newFromParcel(Parcel p) |
void |
setSubId(int subId)
set Subscription information
|
static boolean |
shouldAppendPageNumberAsPrefix()
Check where to add " x/y" in each SMS segment, begin or end.
|
public static final int ENCODING_UNKNOWN
public static final int ENCODING_7BIT
public static final int ENCODING_8BIT
public static final int ENCODING_16BIT
public static final int ENCODING_KSC5601
public static final int MAX_USER_DATA_BYTES
public static final int MAX_USER_DATA_BYTES_WITH_HEADER
public static final int MAX_USER_DATA_SEPTETS
public static final int MAX_USER_DATA_SEPTETS_WITH_HEADER
public static final String FORMAT_3GPP
public static final String FORMAT_3GPP2
public SmsMessageBase mWrappedSmsMessage
public void setSubId(int subId)
public int getSubId()
@Deprecated public static SmsMessage createFromPdu(byte[] pdu)
createFromPdu(byte[], String)
instead.SMS_RECEIVED_ACTION
broadcast
intent must now pass the new format
String extra from the intent
into the new method createFromPdu(byte[], String)
which takes an
extra format parameter. This is required in order to correctly decode the PDU on
devices that require support for both 3GPP and 3GPP2 formats at the same time,
such as dual-mode GSM/CDMA and CDMA/LTE phones.public static SmsMessage createFromPdu(byte[] pdu, String format)
Telephony.Sms.Intents.SMS_RECEIVED_ACTION
as the format
String extra, and will be either "3gpp" for GSM/UMTS/LTE messages in 3GPP format
or "3gpp2" for CDMA/LTE messages in 3GPP2 format.pdu
- the message PDU from the
Telephony.Sms.Intents.SMS_RECEIVED_ACTION
intentformat
- the format extra from the
Telephony.Sms.Intents.SMS_RECEIVED_ACTION
intentpublic static SmsMessage newFromCMT(String[] lines)
public static SmsMessage newFromParcel(Parcel p)
public static SmsMessage createFromEfRecord(int index, byte[] data)
index
- Index of SMS record. This should be index in ArrayList
returned by SmsManager.getAllMessagesFromSim + 1.data
- Record data.public static int getTPLayerLengthForPDU(String pdu)
public static int[] calculateLength(CharSequence msgBody, boolean use7bitOnly)
msgBody
- the message to encodeuse7bitOnly
- if true, characters that are not part of the
radio-specific 7-bit encoding are counted as single
space chars. If false, and if the messageBody contains
non-7-bit encodable characters, length is calculated
using a 16-bit encoding.public static ArrayList<String> fragmentText(String text)
text
- text, must not be null.ArrayList
of strings that, in order,
comprise the original msg textpublic static int[] calculateLength(String messageBody, boolean use7bitOnly)
messageBody
- the message to encodeuse7bitOnly
- if true, characters that are not part of the radio
specific (GSM / CDMA) alphabet encoding are converted to as a
single space characters. If false, a messageBody containing
non-GSM or non-CDMA alphabet characters are encoded using
16-bit encoding.public static SmsMessage.SubmitPdu getSubmitPdu(String scAddress, String destinationAddress, String message, boolean statusReportRequested)
scAddress
- Service Centre address. Null means use default.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, short destinationPort, byte[] data, boolean statusReportRequested)
scAddress
- Service Centre address. null == use defaultdestinationAddress
- the address of the destination for the messagedestinationPort
- the port to deliver the message to at the
destinationdata
- the data for the messageSubmitPdu
containing the encoded SC
address, if applicable, and the encoded message.
Returns null on encode error.public String getServiceCenterAddress()
public String getOriginatingAddress()
public String getDisplayOriginatingAddress()
public String getMessageBody()
public SmsMessage.MessageClass getMessageClass()
public String getDisplayMessageBody()
public String getPseudoSubject()
public long getTimestampMillis()
public boolean isEmail()
public String getEmailBody()
public String getEmailFrom()
public int getProtocolIdentifier()
public boolean isReplace()
public boolean isCphsMwiMessage()
public boolean isMWIClearMessage()
public boolean isMWISetMessage()
public boolean isMwiDontStore()
public byte[] getUserData()
public byte[] getPdu()
@Deprecated public int getStatusOnSim()
public int getStatusOnIcc()
@Deprecated public int getIndexOnSim()
public int getIndexOnIcc()
public int getStatus()
public boolean isStatusReportMessage()
public boolean isReplyPathPresent()
TP-Reply-Path
bit is set in
this message.public static boolean hasEmsSupport()
public static boolean shouldAppendPageNumberAsPrefix()