looper
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
Can’t create handler inside thread that has not called Looper.prepare() inside AsyncTask for ProgressDialog
The method show() must be called from the User-Interface (UI) thread, while doInBackground() runs on different thread which is the main reason why AsyncTask was designed. You have to call show() either in onProgressUpdate() or in onPostExecute(). For example: class ExampleTask extends AsyncTask<String, String, String> { // Your onPreExecute method. @Override protected String doInBackground(String… params) … Read more