Explanation of SmsManager for Android Development

Source: Internet
Author: User

Explanation of SmsManager for Android Development

SmsManager is another very common service provided by Android. SmsManager provides a series of sendXxxMessage () methods for sending text messages.

SmsManager: Manages SMS operations, such as sending data, text messages, and PDU messages. Call the static method SmsManager. getDefault () to obtain this object.

Public Methods

ArrayList

DivideMessage (String text)

When the length of a text message exceeds the maximum length of the SMS message, the text message is divided into several parts.

Static SmsManager

GetDefault ()

Obtain the default SmsManager instance.

Void

SendDataMessage (String destinationAddress, String scAddress, short destinationPort, byte [] data, PendingIntent sentIntent, PendingIntent deliveryIntent)

Sends SMS-based data to the specified application port.

Void

SendMultipartTextMessage (String destinationAddress, String scAddress, ArrayList Parts, ArrayList SentIntents, ArrayList DeliveryIntents)

Send a multi-part text message based on SMS.

DivideMessage(String text) Splits messages into correct sizes.

Void

SendTextMessage (String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)

Send an SMS-based text.

Note:

· ArrayList DivideMessage(String text)
When the length of a text message exceeds the maximum length of the SMS message, the text message is divided into several parts.
Parameters: Text-- The initial message cannot be blank.
Return Value: Ordered ArrayList , Can be combined into an initial message

· Static SmsManagerGetDefault()
Obtain the default SmsManager instance.
Return Value:SmsManagerDefault instance

· VoidSendDataMessage(String destinationAddress,String scAddress,Short destinationPort,Byte [] data,PendingIntent sentIntent, PendingIntent deliveryIntent) sends an SMS-based data to the specified application port.
Parameters:
1 ),DestinationAddress-- Target address of the message
2 ),ScAddress-- The service center address or is null. Use the current default SMSC 3)DestinationPort-- Target Port Number of the message
4 ),Data-- The message body, that is, the data to be sent by the message
5 ),SentIntent-- If it is not null, The PendingIntent is broadcast when the message is successfully sent or fails. The result code is Activity. RESULT_ OK, indicating success, or RESULT_ERROR_GENERIC_FAILURE, RESULT_ERROR_RADIO_OFF, RESULT_ERROR_NULL_PDU, indicating an error. Corresponding to RESULT_ERROR_GENERIC_FAILURE,SentIntentIt may include an additional "error code" that contains a specific value of radio broadcast technology, which is generally only useful for fault fixing.
Every SMS-based application control DetectionSentIntent. IfSentIntentYes, the caller will detect all unknown applications, which will cause a small number of SMS messages to be sent during the detection.
6 ),DeliveryIntent-- If it is not null, the message is broadcast when it is successfully delivered to the recipient's PendingIntent.
Exception: IfDestinationAddressOrDataIf it is null, an IllegalArgumentException exception is thrown.

· VoidSendMultipartTextMessage(String destinationAddress,String scAddress,ArrayList Parts ,ArrayList SentIntents, ArrayList DeliverIntents)
Send a multi-part text message based on SMS. DivideMessage(String text) Splits messages into correct sizes.
Parameters:
1 ), DestinationAddress-- Target address of the message
2 ), ScAddress-- The service center address or is empty. Use the current default SMSC.
3 ), Parts-- Ordered ArrayList , Can be combined into an initial message
4 ), SentIntents-- Follow SendDataMessageThe method is the same, but here is a set of PendingIntent
5 ), DeliverIntents-- Follow SendDataMessageThe method is the same, but here is a set of PendingIntent
Exception: If DestinationAddressOr DataIf it is null, an IllegalArgumentException exception is thrown.

· VoidSendTextMessage(String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)
Send an SMS-based text. The parameter has the same meaning as the existing one before the exception.

For SmsManager application examples, refer to: sending text messages in Android development.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.