Create a simple LooperThread
suggest changeThe platform sample starts a thread, calls Looper.prepare(), creates a Handler on that thread, then calls Looper.loop(). The Handler is created after prepare, so it is bound to this thread. loop() does not return until the looper quits.
class LooperThread extends Thread {
public Handler mHandler;
public void run() {
Looper.prepare();
mHandler = new Handler() {
public void handleMessage(Message msg) {
// process incoming messages here
}
};
Looper.loop();
}
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents