我有 AsyncTask 在后台完成的任务。在某些时候,我需要发出一个 Toast 来表示某事已完成。
我尝试过但失败了,因为
Caused by: java.lang.RuntimeException: Can't create handler inside the thread that has not called Looper.prepare()
我该怎么做?
最佳答案
onPostExecute - 在 UI 线程上执行
或者
publishProgress()
;在你的 doinbackground 和
protected void onProgressUpdate(Integer... progress) {
}
http://developer.android.com/reference/android/os/AsyncTask.html
关于android - 如何在 AsyncTask 中举杯,提示我使用 Looper,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2837676/