Android messagequeue mechanic

Source: Internet
Author: User

Android messagequeue mechanic

Core classes:

Handler-the operator, user apps use this to operate the messages: Send messagewith postrunnable, sendmessage etc. And process messages in handlemessage.

Message-the container for the data andinformation

Messagequeue-the internal containers formessages. User apps are not allowed to operate it directly. It is operatedinternally by Handler

Logoff-the rules which let thread rununtil stop () is called. This is much like use a while (true) in the thread tomake it run as long as you wish

The general message processing wocould be like this:

1. Make the thread (either main thread or user-created thread) can loop, with calling logoff. Prepare ();

2. Send the message with handler.

3. overridehandler. handlemessage to process the message;

4. Stop the logoff by callinglo.pdf. Stop (), then thread will exit.

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.