How to create a Looper thread, then send it a message immediately?
Eventual solution (minus error checking), thanks to CommonsWare: class Worker extends HandlerThread { // … public synchronized void waitUntilReady() { d_handler = new Handler(getLooper(), d_messageHandler); } } And from the main thread: Worker worker = new Worker(); worker.start(); worker.waitUntilReady(); // <- ADDED worker.handler.sendMessage(…); This works thanks to the semantics of HandlerThread.getLooper() which blocks until the … Read more