Android asynchronous Message processing mechanism allows you to deeply understand the relationships among logoff, Handler, and Message, and androidlogoff
Reprinted please indicate the source: http://blog.csdn.net/lmj623565791/article/details/38377229
Android uses Handler to implement message delivery mechanism (2). androidhandler
Before starting this article, let's summarize some key points about Handler, logoff, and MessageQueue in the first two articles:
0) before creating a Handler in the
Speaking of handler in Android, let's first talk about the mechanism and principle of handler.1. Handler mechanism Principle
Handler:It is mainly used to process sending and receiving messages. It is used to add messages to a specific logoff
Before also because weekend night watching TI3 competition, has not found the time to write a blog, resulting in a long period of not updated. Ashamed! Back to the progress of the next, try to make sure to write every week. Here is also the first to
Android UI operations are not thread-safe, and only the main thread can operate the UI. At the same time, the main thread has a certain time limit on UI operations (up to 5 seconds ). To perform some time-consuming operations (such as downloading
Android message processing has three core classes: logoff, handler, and message. There is also a message queue, but MQ is encapsulated into logoff, handler plays the role of adding and processing messages to MQ (only processing messages sent by
Reprint Annotated Source: http://blog.csdn.net/xiaohanluo/article/details/51994401Jiang Answer: HTTP://WWW.JIANSHU.COM/P/E72ABA99012ABrief introductionIn Android development often encounter the situation of asynchronous message processing, in
Message: messages, which contain message IDs, message processing objects, and processed data, are unified by MessageQueue, and eventually handled by handler.
Handler: Processor, responsible for message delivery and processing. When using handler,
Handler mechanism learning Summary
I. Functions of handler
First explain why handler is needed. The main thread needs to execute a time-consuming operation and update the UI accordingly based on the operation results. However, Android reports an ANR
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.