Simple to master the process of sending and receiving MMS and its accessories in Android development _android

Source: Internet
Author: User

A. MMS Send:
MMS is much more troublesome than SMS. You can see from the parameters of the Sendmmsworker function: (CONV, Mmsuri, Persister, slideshow, sendreq) context, Uri,pdupersister (MMS is a PDU), slideshow Contains all the MMS information, Sendreq contains the headers of the MIME package MMS, also includes information such as From,to.
(1) Function Sendmmsworker:

private void Sendmmsworker (conversation conv, Uri Mmsuri,  
 
    pdupersister persister, Slideshowmodel slideshow, SendReq Sendreq) { 
 
  ... 
 
}  

There's a long piece of code before you check this dialog (conversation) For information that is not being sent. Need to mention Messagestatuslistener, The interface interface is defined in the Workingmessage.java, and the implementation is in Composemessageactivity.java, so the former can easily invoke some of the functions of the latter to make the corresponding changes when some states change. Messagestatuslistener mainly include: onprotocolchanged MMS message Switching, onattachmentchanged attachment changes, onpremessagesent send message before, After Onmessagesent sent the message. This calls the Onpremessagesent listener function, and then composemessageactivity calls the Resetmessage function, which adjusts the display, focus, soft keyboard, and so on.
Check the Mmsuri. If the URI is empty, create a new URI and continue sending. This createdraftmmsmessage (Persister, Sendreq, slideshow); The function can contain all the information that is required to send, and if the URI is not empty, the call is Updatedraftmmsmessage (Mmsuri , Persister, slideshow, sendreq); In short, the function is to send the MMS, save disk, that is, save draft.
Deletedraftsmsmessage Delete Drafts.
Create a mmsmessagesender and use this sender to invoke the SendMessage function.
If the function return value indicates that just sent out is actually a SMS SMS. So we have to delete the draft that are stored in the database.
Call Onmessagesent this listener function, call Composemessageactivity's onmessagesent, this function is to display conversationlist again.
(2) Createdraftmmsmessage (Persister, Sendreq, slideshow); and Updatedraftmmsmessage (Mmsuri, Persister, slideshow, sendreq); The two functions are essentially the same, saving the contents of the attachment as pdubody, and updating the URI.
3 Mmsmessagesender.java class, under Mms/transaction, implements the Messagesender interface, which SendMessage and returns a Boolean value. Returns true if MMS is being sent. Returns False if SMS is sent.

Single card mobile phone MMS sent by the sequence diagram as shown in the picture

Dual-card mobile phone MMS sent by the sequence diagram as shown in Figure 1.5:

Two. MMS Receiving
the sequence diagram received by MMS is shown in Figure 1.3:

Third, receive Wappush information and MMS accessories add Delete
the sequence diagram received by 1..Wappush is shown in the figure:

2. MMS Accessories Add Delete
MMS Attachment Add: The addattachment (int type) function in Composemessageactivity is divided into 7 case according to the type

    • Mediaselectlistactivity.add_image
    • Mediaselectlistactivity.take_picture
    • Mediaselectlistactivity.add_video
    • Mediaselectlistactivity.record_video
    • Mediaselectlistactivity.add_sound
    • Mediaselectlistactivity.record_sound
    • Mediaselectlistactivity.add_slideshow

The application that reads the media data from the outside activity is returned to the Onactivityresult () function.

Delete the attachment, attachmenteditor inside there is a handler, used to send messages to composemessageactivity. All buttons for removing attachment actions are on attachmenteditor. There are different buttons for different media types, but the exit is the same when pressed, because all attachments exist in Slideshowmodel, and this slideshowmodel is: arraylist<slidemodel> Mslides; Composed of a list of children slide. Each slide can contain video,image,audio,text, in which the first three are generally not 22 simultaneous, the only exception being image and audio.
To return to that remove operation, the Handlemessage function in Composemessageactivity's handler, after receiving the removal of MSG, is setattachment ().

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.