Topics on Android MMS: Draft Management

Source: Internet
Author: User

After editing a piece of information, if you exit the editing page without sending it, the information is automatically saved as a draft. That is, if onstop () of composemessageactivity is not sent, workingmessage. savedraft () is called to save the information as a draft. During this period, some conditions will also be checked, such as whether the message has been marked as abandoned, or whether it is empty (isworthsaving). If everything is normal, the savedraft () toast will be used to notify you that the information has been saved as a draft.

The saving of the draft is also different for different information, and the SMS and MMS processes are different.

Save SMS as draft

Workingmessage will first extract the text message content, and then start a new thread to do the next thing. workingmessage. savedraft () will also return this. In the thread, ensure that the threadid is correct. If the threadid is not correct, it will not be saved. Then, write the letter into the database and identify the type as draft. At last, the MMS drafts owned by this thread will be deleted. Because only one draft is available in a thread, if a new SMS draft is available, the old MMS drafts will be deleted. Similarly, the draft text message will also be deleted when you save the draft MMS later.

Save mms as draft

Similar to saving text messages, composemessageactivity calls workingmessage during onstop. savedraft (); workingmessage. savedraft () will first refresh the recipient information, then create a MMS Data Structure sendreq, then start the thread to do other things, And savedraft () will return this. In a thread, ensure that it is a valid thread, that is, the threadid must be correct. At the same time, we also need to draft the thread mark, which is managed by a draftcache, which is a hashmap to identify which threads contain draft. If this thread has no attachments before, create an attachment for it, that is, write sendreq to the database. On the contrary, if an attachment already exists, update the database and set sendreq and slideshow, the date is updated to the current information. Finally, delete the draft text message.

The operation of MMS is performed by COM. google. android. MMS. * The classes and tools provided in the package are used to complete the operation. It will provide the data structure sendreq of the MMS supported by Android, and the data (text, medias, files) put the sendreq method pdupart and pdubody, write sendreq to the database, and read sendreq from the data-through pdupersister. The client application only creates sendreq, writes data to sendreq using the provided method, writes data to and extracts data from the database using pdupersister, and finally sends sendreq over HTTP.

There is also a special class draftcache used to manage which threads contain drafts, which is a hashmap internally and can identify which therad contains drafts. Therefore, draftcache is used in the draft operation. If a thread contains a draft, it must mark its threadid as a draft. If the information of a thread has been sent out, we need to mark it as not including draft.

In traditional folders, a folder used to store drafts is called a draft box. Each time you edit the information, no matter which person you send it to, you can put it in this draft box. However, we can also find that, unlike traditional folders, the MMS draft in Android is one thread and only one. In other words, it is impossible to store too many drafts. Because MMs in Android manages information in the thread mode, and one thread and one conversation should only have one not "finished", this design is also common sense.

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.