如何在AsyncTask中举杯,提示我使用Looper [英] How to raise a toast in AsyncTask, I am prompted to used the Looper

查看:24
本文介绍了如何在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 because Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

我该怎么做?

推荐答案

onPostExecute - 在 UI 线程上执行或者publishProgress();在你的 doinbackground 和

onPostExecute - executes on UI thread or publishProgress(); in your doinbackground and

protected void onProgressUpdate(Integer... progress) {
}

http://developer.android.com/reference/android/os/异步任务.html

这篇关于如何在AsyncTask中举杯,提示我使用Looper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆