The main message,handler,messagequeue,loop are:
1.Message and handler with:
Message message = new Message (); message.what = update_text;handler.sendmessage (message); Send the Message object out
Private Handler Handler = new Handler () {public void Handlemessage (Message msg) {switch (msg.what) {case update_text://in this UI Operation Text.settext ("Nice to Meet You"); break;default:break;}};
Message all the Members have
| public int |
Arg1 |
Arg1 and Arg2 is lower-cost alternatives to the using if you only setData() need to store a few integer values. |
| public int |
Arg2 |
Arg1 and Arg2 is lower-cost alternatives to the using if you only setData() need to store a few integer values. |
| Public Object |
Obj |
An arbitrary object to send to the recipient. |
| Public Messenger |
ReplyTo |
Optional Messenger where replies to the message can be sent. |
| public int |
What |
User-defined message code So, the recipient can identify what's this message was about. |
A message is an information that is passed between threads, which can carry a small amount of info inside a line
Exchange data between processes. In the previous section, we used the What field of the Message, in addition to making
Use the Arg1 and Arg2 fields to carry some integer data, using the Obj field to carry a single Object object.
To bring more data, you can use SetData (Bundle).
2 Handler
Handler, as the name implies, is the meaning of the processor, which is primarily used to send and process messages. Send and Cancel
The Handler SendMessage () method is used, and the messages sent are processed in a series of
Will eventually be passed to Handler's Handlemessage () method.
3 MessageQueue
MessageQueue is the meaning of Message Queuing, which is primarily used to store all messages sent through Handler.
This part of the message will remain in the message queue and wait for it to be processed. There will only be one MessageQueue in each thread
Object.
4 Loop
Looper is the steward of MessageQueue in each thread, and after calling the Looper loop () method, it
into an infinite loop, and then whenever a message is found in the MessageQueue, it is taken
and passed to the Handler handlemessage () method. There will only be one Looper object in each thread.
Asynchronous processing in Android