This article is very good, simple, the key is a junior students to analyze their own experience. This is the reason why I like this article. Please see the text below:
As a junior preparatory programmer, I learn the fun of Android is to learn from the source code Google Daniel's design ideas. The Android SDK has a lot of design patterns in it, and in addition to that, it has designed a variety of helper classes for us, and it's too much to read for someone like me who wants to get to the next l
Analysis of the above article, the basic understanding of the implementation of the principle of handler, by hot iron, here we use the handler principle, in the sub-thread to create a handler and LooperMaybe a lot of interviews ask, can I get a new handler in the sub-thread?The answer is yes, but since the main thread
Original address: Http://www.cnblogs.com/codingmyworld/archive/2011/09/12/2174255.html#!commentsAs a junior preparatory programmer, one of my great pleasures in learning Android is that I can learn the design ideas of Google Daniel through the source code. Android source contains a large number of design patterns, in addition, the Android SDK also carefully designed for us a variety of helper classes, for me as eager as the level of the people who want to be advanced, it is worth reading. This i
We know that wirelessly's UI thread is not thread-safe, we can't take time out in the UI thread, and it's usually our practice to turn on a sub-thread to handle time-consuming operations in a child thread, but Android does not allow UI updates to be performed on child threads, and usually we do that with the handler mechanism. , that is, when the time-consuming operation in the child thread completes, the message is sent to the main thread in the chil
message instance available in the message pool,A Message object is created with the given parameters. When Removemessages () is called, the message is removed from the message queue and placed in the message pool. Except for the abovemethod, you can also get a message instance from the handler object's Obtainmessage ().3, Looper:Is the manager of MessageQueue. Each MessageQueue can not be separated from the Loope
message system and simple principle.Let's learn the fundamentals of the messaging system.The basic principle and composition of the two-message systemThe establishment of a generic message system model roughly consists of the following parts:L Message PrototypeL Message QueuingL Send a messageL message loopL Message AcquisitionL Message DistributionL Message ProcessingThe approximate model diagram is as follows: The message system model typically includes the above seven parts (message proto
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, you need to implement the Handlemessage (Message msg) method to handle a particular message, such as updating the UI.
from the 2.3 Runtime is that the UI component is manipulated in a non-UI thread. No, Magic, Asynctask#onprogressupdate () and Asynctask#onpostexecute () documents clearly written that these two callbacks are in the UI thread, how to report such an exception!
Cause AnalysisAsynctask designed to perform asynchronous tasks but can communicate with the main thread, it has an internal internalhandler is inherited from the handler static member Shandler,
Android's message processing has three core classes: Looper,handler and message. There's actually a message queue, but MQ is encapsulated in Looper, and we don't deal directly with MQ, so I don't use it as a core class. Here are the following:Thread of the magician LooperLooper literally means "circulator", which is designed to make a normal thread into a
first, take a look at the use of the process1. Using handler instances in child threads /*********** Child Threads Use Handler instance *********/ private class Looperthread extends thread {public Handler Handler; @Override public Void Run () { looper.prepare ();
A lot of people interviewed must have been asked, what is the relationship between Looper, Handler, and message in Android? The purpose of this blog is to introduce 3 relationships from the source point of view, and then give a conclusion that is easy to remember.1. Overview handler, Looper, and message all three conce
IntroductionWhen we do Android development, we often need to implement the asynchronous loading of images/Web pages/other. In fact, to implement asynchronous loading, you need to implement inter-thread communication, while in Android, using Handler, Looper, and Message enables different threads to communicate and complete asynchronous tasks. Although Android has provided us with the Asynctask class to accom
In the previous blog post, two typical instances of inter-thread communication based on the handler Looper mechanism in Android were given. In this paper, the basic principles of this mechanism are studied in depth. Personally think, learn Android programming the best teacher is the source code of Android, the following will be based on the Android-19 source for analysis, focusing on the analysis of ideas.T
Android Threading message passing mechanism--looper,handler,messageBefore introducing these concepts, let's look at the context in which these mechanisms are introduced.For performance optimizations, Android UI operations are not thread-safe (if you don't know what thread safety is, you can read Here's a question: What if your Android program wants to download a picture on the Web (we don't consider using A
Android's message processing has three core classes: Looper,handler and message. There's actually a message queue, but MQ is encapsulated in Looper, and we don't deal directly with MQ. Usually we use the most often is the message and handler, if the use of handlerthread or their own implementation of similar handlerthr
1. The relationship between Handler Looper MessageQueue2. Source Code AnalysisRepresents the relationship between the four classes of handler, Looper, MessageQueue, and message.
The handler must be associated with a looper
The role of handler is to send a message and handle the message sent by Message,handler is actually sent to its own object for processing, so who is sent who is handling, but this absolutely makes sense, So that we can move the processing of the message from one thread to another through handler, after a message has changed hands, the object that handles it is th
Objective:The previous article is about bitmap and memory optimization technology, this article to everyone talk about handler.Handler is an important knowledge of the Android system, which is often asked in Android multithreaded interviews and is often used in real-world projects. Of course, more complex, more knowledge, involved in the class has thread, Looper, Message, MessageQueue.Android is multi-threaded, usually the user-related UI events in th
Overview : Android uses messaging mechanisms to communicate between threads, threads create their own message loops through Looper, MessageQueue is a FIFO message queue, Looper is responsible for extracting messages from MessageQueue. and distributes to the message specifies the target handler object. The handler objec
Preface:The previous article is about bitmap and memory optimization technology, this article to everyone talk about handler.Handler is an important knowledge of the Android system, which is often asked in Android multithreaded interviews and is often used in real-world projects. Of course, more complex, more knowledge, involved in the class has thread, Looper, Message, MessageQueue.Android is multi-threaded, usually the user-related UI events in the
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.