Create a simple LooperThread

suggest change

The 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();
    }
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents