Android AsyncTask [Can't create handler inside thread that has not called Looper.prepare()]

后端 未结 2 1256
说谎
说谎 2020-12-29 03:54

I\'ve created an image upload AsyncTask based on a function. And after uploading, I get this error on onPostExecute(). I read up some StackOverflow

2条回答
  •  一个人的身影
    2020-12-29 04:13

    You are attempting to update the UI from a background thread. Either move the toast to onPostExecute, which executes on the UI thread (recommended), or call runOnUiThread.

    runOnUiThread(new Runnable() {
        public void run() {
            // runs on UI thread
        }
    });
    

提交回复
热议问题