In a single-threaded program, the main thread in the processing of big data or access to network resources, the main thread of the UI will tend to get stuck, there is a point of the phenomenon (UI thread is blocked), in this case, the general use of multi-threading, separate open a sub-thread for data processing, this will encounter a problem, How the data updated by the child thread is reflected in the main thread of the UI, which is used by handler, whose primary function is to accept the data sent by the child thread and update the UI with this data in conjunction with the main thread. The use of the concrete is quite simple:
1. Send a message in the child thread string
Message msg = new Message ();
Bundle B = new bundle ();//Store data
B.putstring ("Color", "my");
Msg.setdata (b);
MainActivity.this.myHandler.sendMessage (msg);
2. Handlemessage in handler receives the message and updates the data contained in the receive to the UI interface China
Super.handlemessage (msg);
Bundle B = Msg.getdata ();
String color = b.getstring ("color");
MainActivity.this.buttonStart.append (color);
Asynchronous data Processing Handler