本文介绍了如何在AsyncTask中举杯,提示我使用Looper的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有 AsyncTask 在后台完成的任务.在某些时候,我需要发出一个 Toast 来表示某事已完成.
I have tasks completed by AsyncTask in background. At some point I need to issue a Toast that something is completed.
我尝试过但失败了,因为Caused by: java.lang.RuntimeException: Can't create handler inside the thread that has not Called Looper.prepare()
I've tried and I failed becauseCaused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
我该怎么做?
推荐答案
onPostExecute - 在 UI 线程上执行或者publishProgress()
;在你的 doinbackground 和
onPostExecute - executes on UI threador publishProgress()
; in your doinbackground and
protected void onProgressUpdate(Integer... progress) {
}
http://developer.android.com/reference/android/os/异步任务.html
这篇关于如何在AsyncTask中举杯,提示我使用Looper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!