多个异步任务不是在安卓4.1上运行 [英] Multiple Async Task not running in android 4.1

查看:117
本文介绍了多个异步任务不是在安卓4.1上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用我使用3个不同的异步任务。
2任务在活动正在运行和第三的是在活动B.当我运行在OS的模拟器版本2.3的应用程序工作正常的应用程序。但是,当我试图在Android 4.0以上的版本只第一AsyncTask的运行。

In my android app i'm using 3 different async task. 2 tasks are running in Activity A and 3rd one is in Activity B. While i'm running the app in Emulator of OS version 2.3 application is working fine. But while i'm trying in Android 4.0 or higher version only first Asynctask is running.

有没有办法在4.0及更高版本上运行的所有3异步任务?

Is there any way to run all the 3 Async tasks in 4.0 and higher version?

推荐答案

您可以执行以下操作:

YourAsyncTaskClassObjectName.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

YourAsyncTaskClassObjectName.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

代替正常执行:

YourAsyncTaskClassObjectName.execute()

YourAsyncTaskClassObjectName.execute()

这实际工作对我的简单的非商业应用程序。现在,我已经2 asynctasks永远运​​行doInBackground方法(我而(真)内的每个)。

This actually worked for my simple non business app. Now, I've the doInBackground methods of two asynctasks running forever (i've while(true) inside each).

警告:我不是说这是最好的设计,但其实这工作

Caveat: I'm not saying this is the best design but this actually worked.

这篇关于多个异步任务不是在安卓4.1上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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