Gamecraftler Gamecraftler - 1 year ago 57
Java Question

How to start a new Activity after several async tasks had finished

I have a big Problem:

I want to start a new Activity after several Async-Tasks had finished.
My problem is that the Async-Tasks are dynamically started. Some time I have only one Async-Task, some time I have five Async-Tasks.
And the even bigger problem is, that all are the same Async-Tasks, only with another URL. Because they're Download-Tasks.

Could anyone help?


I created a counter that every available Update counts 1 higher. So if five Updates are available, the counter will be set to 5. Each finished Update and Unzip, the counter will be set 1 lower. If

counter == 0
it would open the new Activity.

Thanks for all of your Answers.

Answer Source

Use a global variable counter assigned with number of AsynTasks,
On every onPostExecute decrement the counter

ON if(counter ==0) Start your new Activity

class A{
int counter =0;

public doJob(int jobCOunt){
    this.counter = jobCount
    new Job().execute();
class Job extends AsyncTask{
  protected void onPostExecute(Boolean success) {
    if(counter == 0){


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download