Sort out common SMS interfaces for Android 4.2.1

Source: Internet
Author: User

Long-winded: I found my blog was reposted, but I didn't specify the source. It felt a little painful and happy. Here we formally declare: reprinted, please indicate the source, thank you. If you have commercial purposes, please be sure to inform me.

 

The SMS function on Android is basically stable and rarely maintained, so it is always unfamiliar. % >_< % Here we will summarize the text message interfaces used by native MMS on 4.2.1 for memory. The interfaces provided by the android framework for upper-layer text messages are basically smsmanager and smsmessage. In my personal summary, the former mainly provides SMS sending and its peripheral functions, and the latter provides the function of calculating the length of resolution text message encoding and other functions for text message content.
Let's talk about the smsmanager class:
According to the subsequent call, sendtextmessage () is the method for sending a text message on the protocol. A text message on the Protocol means that a text message cannot exceed 140 bytes, that is, 70 Chinese characters. This method is not called in native text messages and is used in another method of this class.
Dividemessage () divides a string into several text message segments based on the protocol. This method will be used in smssinglerecipientsender. Java, the class that the native SMS module sends the final text message. Pay attention to this method to find a long text message, starting from the second broken text message, because some fields are added for storage content to become smaller.
In sendmultiparttextmessage () Android native code, the text messaging method called by the application layer. It has nothing to do with the application from here on.
Senddatamessage () can be understood literally, but it has never been seen where it has been used. The crowdsourced security testing uses this method.
Copymessagetoicc () does not see where to use it, as well as crowdsourced security testing.
Deletemessagefromicc () is used in the SMS database to delete text messages from SIM cards.
Updatemessageonsim () is rarely used.
Getallmessagesfromicc () is still used in the SMS database.
The following methods are basically irrelevant to the short message function. We can see that here we only need to remember and be familiar with the sendmultiparttextmessage () and dividemessage () interfaces. If it is necessary to write the SMS sending function code, these two interfaces are enough.
Let's talk about smessage. The methods in this class can be said to be implemented one by one according to the protocol. The note also illustrates the reference to the TS 23.038 protocol.
Createfrompdu () parses the content from the following broadcast into a text message when you receive the text message according to the comment. Native text messages use the overload method of this method.
Createfrompdu () is an overloaded method. An additional text message type is added to the parameter list. Because GSM and cdma sms decoding methods are different. The lower layer will provide the current text message type when sending broadcasts to the upper layer. Based on this type, you can know whether to use GSM or CDMA to parse the text message.
Newfromcmt (), newfromparcel (), createfromefrecord (), and gettplayerlengthforpdu () are generally not commonly used. Just get an impression.
Calculatelength () calculates the information after the current text message is packaged according to the protocol, including the number of segments that need to be packaged into the text message, and the amount of space remaining in the last segment. It is useful in the updatecounter method that shows the remaining words on the composemessageactivity. Java text message editing interface.
Fragmenttext () is used in smsmanager and dividemessage. The subsequent methods are the get method, which returns some tags of the SMS type.

Finally, some methods and scopes are preceded by the @ hide field, indicating that APIs are not made public, but can be used inside the system. However, reflection may also be used. :) The interfaces commonly used in text messages are sorted here to facilitate future memory. I hope I can take these to see the 3GPP protocol. :)

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.