Smsmanager is another very common service offered by Android, Smsmanager provides a series of sendxxxmessage () methods for sending SMS messages.
Smsmanager: Manage SMS operations, such as sending data, text and PDU text messages. Gets this object by calling the static method Smsmanager.getdefault () .
|
Public Methods |
|
|
ArrayList<String> |
Dividemessage (String text)
when SMS exceeds SMS The maximum length of the message, split the text message into chunks. |
|
|
|
|
|
|
|
|
|
|
|
Static Smsmanager |
Getdefault ()
Get Smsmanager the default instance. |
|
|
|
|
|
|
|
|
|
|
|
void |
Senddatamessage (string destinationaddress , string scaddress, short destinationport, byte[] data, pendingintent sentintent, pendingintent deliveryintent)
send a message based on SMS the data to the specified application port. |
|
|
|
|
|
|
|
|
|
|
|
void |
Sendmultiparttextmessage (string destinationaddress, string scaddress, ArrayList<string > Parts, ArrayList<pendingintent> sentintents, ArrayList <pendingintent> Deliveryintents)
Sends an SMS-based multipart text that the caller app has passed by calling
Dividemessage (String text) splits the message into the correct size. |
|
|
|
|
|
|
|
|
|
|
|
void |
Sendtextmessage (string destinationaddress, string scaddress, string text, pendingintent sentintent, pendingintent deliveryintent)
send a message based on SMS the text. |
|
|
|
|
|
|
|
|
|
|
Description
· arraylist<String> Dividemessage(String text)
when SMS exceedsSMSThe maximum length of the message, split the text message into chunks.
Parameters:text--initial message, cannot be empty
return value: an orderly ArrayList<String> that can be re-assembled into the initial message
· static smsmanager getdefault()
Get Smsmanager the default instance.
return value : Smsmanager the default instance
· void senddatamessage (String destinationaddress, String scaddress, Short destinationport, byte[] data, pendingintent Sentintent,pendingintent deliveryintent)send a message based onSMSthe data to the specified application port.
Parameters:
1),destinationaddress--Destination Address of the message
2),scaddress--Address of the service centeroruse the current default for nullSMSC 3) destinationport--Destination port number of the message
4),Data--The body of the message, the data to be sent by the message
5),sentintent--if it is not empty, when the message is sent successfully or fails thispendingintenton the radio. The result code isACTIVITY.RESULT_OKindicates success, orresult_error_generic_failure,Result_error_radio_off,RESULT_ERROR_NULL_PDUone represents an error. correspondingresult_error_generic_failure,sentintentmay include additional"Error code"contains a radio broadcast technology-specific value that is usually only useful in repairing a failure.
each one based onSMSthe application control detectionsentintent. Ifsentintentis NULL, the caller will detect all unknown applications, which will cause a smaller number of messages to be sent at the time of DetectionSMS.
6),deliveryintent--if it is not empty, when the message is successfully delivered to the receiver, thispendingintenton the radio.
Exception: IfdestinationaddressorDatais empty when thrownillegalargumentexceptionexception.
· void sendmultiparttextmessage (String destinationaddress, String scaddress, ArrayList<String> parts,ArrayList<pendingintent> sentintents,arraylist<pendingintent> deliverintents)
send a message based onSMSthe multi-part text that the caller app has passed by callingDividemessage(String text)splits the message into the correct size.
Parameters:
1),destinationaddress--Destination Address of the message
2),scaddress--Address of the service centeroruse the current default for nullSMSC
3),Parts--Order of ArrayList<String> that can be re-assembled into the initial message
4),sentintents--withSenddatamessagemethod, except that there is a set ofpendingintent
5),deliverintents--withSenddatamessagemethod, except that there is a set ofpendingintent
Exception: IfdestinationaddressorDatais empty when thrownillegalargumentexceptionexception.
· void sendtextmessage (String destinationaddress,String scaddress,String text,pendingintent Sentintent,pendingintent deliveryintent)
send a message based onSMSthe text. The meaning of the parameter is the same as the exception that existed before, no longer a statement of exhaustion.
Application Examples of Smsmanager you can refer to :android development to send SMS
Android Development Smsmanager (SMS Manager) detailed