Listing pending jobs

Unlike the AlarmManager API, the Scheduler API provides the ability to list all the pending schedules for your application. This handy feature could help us to recognize the jobs that are going to be executed in the future and react accordingly with that list. The list retrieved could help us to pinpoint a pending job that we would like to cancel.

The JobScheduler service class has an instance method with the following signature:

public List<JobInfo> getAllPendingJobs();

The method will return a list of JobInfo objects that we can use to observe job parameter sets during the job build:

  • Job criteria for each job:
    • getNetworkType()
    • isRequireDeviceIdle()
    • isRequireCharging()
    • getMinLatencyMillis()
    • isPeriodic()
    • getIntervalMillis()
    • isPersisted() ...

Get Asynchronous Android Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.