运行在onPostExecute另一个AsyncTask的()onPostExecute、AsyncTask

2023-09-07 08:45:24 作者:浅夏ら麦芽糖

如果我需要运行另一个异步任务异步的另一个任务是,这意味着在 onPostExecute()法,该怎么办呢?

What if I need to run another async task being in another async task, meaning in onPostExecute() method, how to do so?

推荐答案

作为一个建议,尝试过负荷的第一个的AsyncTask 成许多个时间的接听电话,你能够。但是,如果你的应用程序设计是这样一种方式,你只需要执行其他任务,一旦第一个任务完成,然后简单地执行第二的AsyncTask 完全一样的方式你正在做的第一个。

As a recommendation, try to off-load as many time's taking calls in your first AsyncTask as you can. However, if your application design is in such a way that you only need to execute another task once the first task is completed then simply execute the second AsyncTask exactly in the same way as you are doing for the first one.

@Override
protected void onPostExecute(String result) {
     new MySecondAsyncTask().execute(params);   //params if any
}