Android SMS module analysis (5) sending and receiving of MMS

Source: Internet
Author: User

I. sending MMS:

MMS is much more troublesome than SMS. It can be seen from the parameters of the sendmmsworker function: (Conv, mmsuri, persister, slideshow, sendreq) Context, Uri, pdupersister (PDU is used for MMS ), slideshow contains all the MMS information. sendreq contains headers for mime encapsulation of MMS, as well as from and to information.

(1) function sendmmsworker:

private void sendMmsWorker(Conversation conv, Uri mmsUri,        PduPersister persister, SlideshowModel slideshow, SendReq sendReq) {   .....}   

There was a long piece of code before, and there was no unsent information before checking the conversation. Messagestatuslistener, which is defined in workingmessage. java, and the implementation is in composemessageactivity. java, so the former can easily call some functions of the latter when the status changes. Messagestatuslistener mainly includes: onprotocolchanged mms sms switching, onattachmentchanged attachments, onpremessagesent before sending messages, onmessagesent after sending messages. Here the onpremessagesent listening function is called, and composemessageactivity will call the resetmessage function, which will adjust the display, focus, and soft keyboard.

Check mmsuri. If this URI is empty, create a new URI to continue sending. The createdraftmmsmessage (persister, sendreq, slideshow) function can contain all the information required for sending. If the URI is not empty, updatedraftmmsmessage (mmsuri, persister, slideshow, sendreq) is called ); in short, the function is to save the MMS to the disk, that is, to save the draft.

Deletedraftsmessage delete draft

Create an mmsmessagesender and use this sender to call the sendmessage function.

If the return value of the function indicates that the sent message is actually an SMS. So we need to delete the draft stored in the database.

Call the onmessagesent listening function and call the onmessagesent of composemessageactivity. This function re-displays the conversationlist.

(2) createdraftmmsmessage (persister, sendreq, slideshow); and updatedraftmmsmessage (mmsuri, persister, slideshow, sendreq); these two functions are essentially the same, save the attachments in the form of pdubody, and update the URI.

3) mmsmessagesender. Java class, which implements the messagesender interface under MMS/transaction. This interface sendmessage and returns a Boolean value. If MMS is sent, true is returned. If SMS is sent, false is returned.

Figure 1.1 shows the sequence of sending a single-card mobile phone MMS Message

Figure 1.5 shows the sequence of Two-card mobile phone MMS messages:

Ii. Receiving MMS

Figure 1.3 shows the sequence of receiving MMS messages:

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.