0

I have an activity in which there are 4 async task.

In that the array is being filled.Now till the time the data is loaded from API i want to show loader and when the array is filled it should disappears.

I know how to show loader for one async task but how can I show one loader for 4 async task.

Can anyone help on this? If any other information is needed, please let know.

Bunny
  • 237
  • 2
  • 13

1 Answers1

1

There are 2 options:

  1. Keep on starting another AsyncTask in the onPostExecute of the prior AsyncTask.
  2. Keep the 4 AsyncTasks in an array. Now create another AsyncTask and in it's doInBackground, keep a while loop running, keep on calling the getStatus() of each task and check whether it has FINISHED. Once the status of all four is FINISHED, then return this AsyncTask's doInBackground and in it's onPostExecute, close the loader.
Eric B.
  • 4,622
  • 2
  • 18
  • 33