A typical example of the implementation of a Looper
thread given by the official documentation uses Looper.prepare()
and Looper.loop()
and associates a Handler
with the loop between these calls.
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();
}
}