The relationship between Android development handler and Looper

Source: Internet
Author: User

a summary of handler.

message: Messages that contain the message ID, the message processing object, and the processed data are queued by MessageQueue and processed by Handler .

Handler: Handler, responsible for sending and processing the message. When using Handler , you need to implement the handlemessage (message msg) method to process a specific message , such as updating the UI such as

MessageQueue: Message Queuing, which holds messages sent by Handler and executes according to FIFO rules. Of course, storing a message is not a meaningful preservation, but rather a concatenation of the message in the form of a linked list, waiting for the Looper to be extracted.

Looper: The message pump continuously extracts message execution from the MessageQueue . Therefore, a MessageQueue needs a Looper.

Thread: Threads that are responsible for dispatching the entire message loop, that is, the execution site of the message loop.

, handler is responsible for stacking the data into the end of the message and extracting the data from the team head, while Looper is responsible for looping out the queue to get handler data. Note that Looper must be the looper of the UI to be able to update the UI interface!


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.