Handler, Handler
Handler's Basic ConceptsHandler provides an asynchronous processing mechanism. There are two queues: one is the queue that puts the thread into, and the other is the message queue. Activity is a thread and download is another thread.Handler basic usageAdd to message queue immediately: post (Runnable object reference), remove from Message Queue: removeCallback (Runnable object reference) 1. create a Handler object 2. write the operation to be executed in the run method of the thread object. 3. in the run method, execute postDelayed (with two parameters) Method 4. call the post method referenced by Handler in the trigger eventRelationship between Handler and threadBy default, Handler is in the same thread as the Activity that calls it. Compile the Thread program: 1. Implement the runnable interface; 2. inherit the Thread class. Both methods have to implement the run method, but the start thread does not call the run method but calls the start method of the thread. If the run method is called directly, instead of actually starting a thread, the run method is executed in the current thread. Post (Runnable object), which is actually a direct run method.Bundle usageIs a data storage tool Bundle (String key, value). key can only be of the String type, value can be of other types.Message Processing Methods in new threadsLogoff cyclically retrieves messages from the queue. When there is no message in the queue, the thread will sleep.