Class Overview
Manages SMS operations such as sending data, text, and pdu SMS messages.
Get this object by calling the static method SmsManager.getDefault().
Summary
Public Methods |
---|
ArrayList<String>
|
divideMessage(String text)
Divide a message text into several fragments, 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, PendingIntent sentIntent, PendingIntent deliveryIntent)
Send a data based SMS to a specific application port.
|
void
|
sendMultipartTextMessage(String destinationAddress, String scAddress, ArrayList<String> parts, ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents)
Send a multi-part text based SMS.
|
void
|
sendTextMessage(String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)
Send a text based SMS.
|
[Expand]
Inherited Methods |
---|
From class java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Called before the object's memory is reclaimed by the VM.
|
final
Class<? extends Object>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
final
void
|
wait(long millis, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long millis)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
|
Constants
public
static
final
int
RESULT_ERROR_GENERIC_FAILURE
Constant Value:
1
(0x00000001)
public
static
final
int
RESULT_ERROR_NO_SERVICE
Failed because service is currently unavailable
Constant Value:
4
(0x00000004)
public
static
final
int
RESULT_ERROR_NULL_PDU
Failed because no pdu provided
Constant Value:
3
(0x00000003)
public
static
final
int
RESULT_ERROR_RADIO_OFF
Failed because radio was explicitly turned off
Constant Value:
2
(0x00000002)
public
static
final
int
STATUS_ON_ICC_FREE
Free space (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27).
Constant Value:
0
(0x00000000)
public
static
final
int
STATUS_ON_ICC_READ
Received and read (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27).
Constant Value:
1
(0x00000001)
public
static
final
int
STATUS_ON_ICC_SENT
Stored and sent (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27).
Constant Value:
5
(0x00000005)
public
static
final
int
STATUS_ON_ICC_UNREAD
Received and unread (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27).
Constant Value:
3
(0x00000003)
public
static
final
int
STATUS_ON_ICC_UNSENT
Stored and unsent (TS 51.011 10.5.3 / 3GPP2 C.S0023 3.4.27).
Constant Value:
7
(0x00000007)
Public Methods
Divide a message text into several fragments, 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, PendingIntent sentIntent, PendingIntent deliveryIntent)
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 PendingIntent is
broadcast when the message is sucessfully sent, or failed.
The result code will be Activity.RESULT_OK for success,
or one of these errors:
RESULT_ERROR_GENERIC_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
For RESULT_ERROR_GENERIC_FAILURE the sentIntent may include
the extra "errorCode" containing a radio technology specific value,
generally only useful for troubleshooting.
The per-application based SMS control checks sentIntent. If sentIntent
is NULL the caller will be checked against all unknown applicaitons,
which cause smaller number of SMS to be sent in checking period. |
---|
deliveryIntent
| if not NULL this PendingIntent is
broadcast when the message is delivered to the recipient. The
raw pdu of the status report is in the extended data ("pdu").
|
---|
Send a multi-part text based SMS. The callee should have already
divided the message into correctly sized parts by calling
divideMessage
.
Parameters
destinationAddress
| the address to send the message to
|
---|
scAddress
| is the service center address or null to use
the current default SMSC
|
---|
parts
| an ArrayList of strings that, in order,
comprise the original message
|
---|
sentIntents
| if not null, an ArrayList of
PendingIntent s (one for each message part) that is
broadcast when the corresponding message part has been sent.
The result code will be Activity.RESULT_OK for success,
or one of these errors:
RESULT_ERROR_GENERIC_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
For RESULT_ERROR_GENERIC_FAILURE each sentIntent may include
the extra "errorCode" containing a radio technology specific value,
generally only useful for troubleshooting.
The per-application based SMS control checks sentIntent. If sentIntent
is NULL the caller will be checked against all unknown applicaitons,
which cause smaller number of SMS to be sent in checking period.
|
---|
deliveryIntents
| if not null, an ArrayList of
PendingIntent s (one for each message part) that is
broadcast when the corresponding message part has been delivered
to the recipient. The raw pdu of the status report is in the
extended data ("pdu").
|
---|
public
void
sendTextMessage
(String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)
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 PendingIntent is
broadcast when the message is sucessfully sent, or failed.
The result code will be Activity.RESULT_OK for success,
or one of these errors:
RESULT_ERROR_GENERIC_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
For RESULT_ERROR_GENERIC_FAILURE the sentIntent may include
the extra "errorCode" containing a radio technology specific value,
generally only useful for troubleshooting.
The per-application based SMS control checks sentIntent. If sentIntent
is NULL the caller will be checked against all unknown applications,
which cause smaller number of SMS to be sent in checking period.
|
---|
deliveryIntent
| if not NULL this PendingIntent is
broadcast when the message is delivered to the recipient. The
raw pdu of the status report is in the extended data ("pdu").
|
---|