Skip to content Skip to sidebar Skip to footer

Android Looper.prepare()

The code shown uses an AsyncTask class to call a blocking process so that the UI is not blocked, and a progressbar is shown. The funny thing is that the onClick method works, but t

Solution 1:

You get an error because Toast.makeToast() is called from background thread. You can't do it in doInBackground() instead return value from this method describing exception and show toast in onPostExecute() if you get this specific value.

Apparently, code in try block fails in one case but not another. That's different from problem with looper.prepare().

Solution 2:

handler.post(showToast);

showToast(){ run().run{ toast...... } }

Post a Comment for "Android Looper.prepare()"