如何运行相同的AsyncTask不止一次? [英] How to run the same asynctask more than once?
本文介绍了如何运行相同的AsyncTask不止一次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我的AsyncTask运行活动时首次启动,那么,如果网络连接不可用,那么我有一个刷新按钮,尝试运行的AsyncTask再试一次。但我得到一个调试错误说这个..
I have my asyncTask run when the activity first starts, then if network connectivity is not available then i have a refresh button that tries to run the asyncTask to try again. But i get a debug error saying this..
07-29 18:14:21.290: ERROR/AndroidRuntime(9080): FATAL EXCEPTION: main
07-29 18:14:21.290: ERROR/AndroidRuntime(9080): java.lang.IllegalStateException: Cannot execute task: the task has already been executed (a task can be executed only once)
07-29 18:14:21.290: ERROR/AndroidRuntime(9080): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:541)
07-29 18:14:21.290: ERROR/AndroidRuntime(9080): at android.os.AsyncTask.execute(AsyncTask.java:499)
07-29 18:14:21.290: ERROR/AndroidRuntime(9080): at com.fttech.gameIT.MainMenu$1.onClick(MainMenu.java:90)
反正有两次运行此?
Is there anyway to run this twice?
推荐答案
刚刚创建另一个实例并执行它。
Just create another instance and execute it.
这篇关于如何运行相同的AsyncTask不止一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文