Android MMS: The application of draft management _android

Source: Internet
Author: User

When you finish editing a message, if you exit the edit page without sending it, the information is automatically saved as a draft. That is, when the Composemessageactivity OnStop () is not sent, then the Workingmessage.savedraft () is invoked to save the information as a draft. The period also checks for conditions such as whether the message has been identified as being discarded, or whether it is empty (isworthsaving), and if everything is normal savedraft () and toast to tell the information to be saved as a draft.
drafts of the preservation is also for different information and different, SMS and MMS flow is different.
Save Text as draft
Workingmessage will take out the text message first, then open a new thread to do the next thing, Workingmessage.savedraft () will return. In a thread, you first make sure that the ThreadID is correct, and if you don't have the correct threadid, you won't save it. The letter is then written into the database and the type is identified as draft. Finally delete this thread has a draft of the MMS, because a thread can only have a draft, so if you have a new text message to delete the old MMS quadrochromatic, the same, behind the save text message quadrochromatic will be deleted when the draft.
Save MMS as draft
Similar to saving SMS, Composemessageactivity calls Workingmessage.savedraft () at OnStop, and Workingmessage.savedraft () refreshes the recipient information First, You will then create a data structure sendreq for the MMS, and then start the thread to do other things, Savedraft () and return. In a thread, first the guarantee is a legitimate thread, that is, the ThreadID is correct. Also want to put this thread mark as having a draft, this is by a draftcache in management, it is a hashmap, to identify which thread contains draft. If this thread does not have an attachment before, then create an attachment for it, that is, to write the sendreq to the database; Conversely, if you already have an attachment, update the database and update the SENDREQ and slideshow to the contents of the current information. Finally delete the draft text that has been SMS.

Here to note that the operation of MMS is frameworks in the com.google.android.mms.* package provided in the class and tools to complete, it will provide the support of Android multimedia data structure sendreq, the data (Text, Medias,files) puts the Sendreq method Pdupart,pdubody, writes the sendreq to the database and reads from the data sendreq-through Pdupersister. The client's application simply creates the Sendreq, writes the data to the sendreq using the provided method, writes the database with Pdupersister and extracts it from the database, and sends the SENDREQ with the HTTP protocol.

There is also a specialized class Draftcache to manage which thread contains drafts, and its interior is a hashmap that identifies which Therad contain drafts. Therefore, the Draftcache is used where the drafts are operated, and if a thread contains a draft, it needs to be labeled as having a draft, and if a thread message has been sent out, it must be identified as containing no drafts.

A traditional folder-managed message has a folder called a draft box that is designed to store drafts. Each time you edit the information, no matter which person you send it to, you can put it in the draft box. But you can also see that, unlike traditional folders, the draft of MMS in Android is one of each thread, and there is only one, in other words, it is impossible to store too many drafts. Because the MMS in Android is to manage information in the form of dialog thread, and a thread, a conversation, there should only be one that is not "finished", so the design is also rational.

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.