安卓:在AsyncTask的HTTP请求不并发AsyncTask、HTTP

由网友(残痕)分享简介:我写的我的本地电影中心风扇的应用程序,这表明筛选日历接下来的几天。每天的膜列表是使用一参数化HTTP从网站调用(答案包含希伯来文,所以如果你点击了链接,并得到了一些废话它可能确定)。I'm writing a fan app for my local cinematheque, which shows the scr...

我写的我的本地电影中心风扇的应用程序< /一>,这表明筛选日历接下来的几天。每天的膜列表是使用一参数化HTTP从网站调用(答案包含希伯来文,所以如果你点击了链接,并得到了一些废话它可能确定)。

I'm writing a fan app for my local cinematheque, which shows the screening calendar for the next few days. The per-day film list is retrieved using a parametrized HTTP call from the site (The answer contains Hebrew, so if you clicked the link and got some Gibberish it's probably OK).

该应用程序会显示在接下来的八天的时间表,所以它使8通话每一天的时间表要求。

The app displays the schedule for the next eight days, so It makes 8 calls with per-day schedule request.

private class GetMoviesTask extends AsyncTask<Integer, Void, List<Film>>

doInBackground()检索每天的电影名单,而 onPostExecute()更新的接口。

doInBackground() retrieves the list of films per day, and onPostExecute() updates the interface.

该AsyncTask的是从 MainActivity.onCreate称为()

The AsyncTask is called from MainActivity.onCreate():

for (int i=0; i<NUMBER_OF_DAYS_TO_VIEW; i++){
    new GetMoviesTask().execute(i);
}

的问题是,AsyncTask的不同时执行。日子正在慢慢装了一个又一个,这是痛苦的缓慢:

The problem is that AsyncTask is not executed concurrently. The days are slowly loaded one after another, which is painfully slow:

什么是同时启动这些AsyncCalls的最佳方法是什么?

What's the best way to start these AsyncCalls concurrently?

推荐答案

的AsyncTask 已经知道打了一个回归的安卓4.x中,在系统执行它们一次的,而不是执行它们兼任它,因为Android 1.6的一样。这是由设计:基本上,在新平台上,你可以通过调用恢复为原来的并发行为 executeOnExecutor()而不是执行()。马克·墨菲(被称为 Commonsware 的计算器)具有的

阅读全文

相关推荐

最新文章