Note: We create a handler object to call the POST method, and then pass it into a runnable object. This method does not create a new thread.
Handlerthread and logoff:Handlerthread is a subclass of thread.
The following is the application framework:
1. First create the handlerthread object
2. enable the new thread by using the start method of the handlerthread object
3. Create a class to inherit handler and call the constructor containing logoff.
Public class myhandler extends handler {
Public myhandler (low.logoff ){
Super (logoff );
}
Public void handlermessage (Message MSG ){}
}
4. Create a myhandler instance and pass in the getlooper of the handlerthread instance as the parameter.
Myhandler handler = new myhandler (New handlerthread. getlooper ());
Message message = handler. obtainmessage ();
// The target is the handler object that obtains the message object.
Message. sendtotarget ();