Search code examples
androidandroid-priority-jobqueue

Android JobQueue - Queue jobs


I have a simple scenario where I would like to queue two jobs, Job A and Job B.

Job B must only be called once Job A has finished.

Setup

I have encapsulated the jobManager object within Application.

App.getJobManager().addJobInBackground(new JobA()); App.getJobManager().addJobInBackground(new JobB());

Job Constructor

Both jobs typically have a constructor that looks like this:

public JobA() // or JobB
{
    super(new Params(1).requireNetwork());
}

Solution

  • You can give both of them the same groupId so that it will not run them parallel. Note that this will still run Job B even if Job A fails.