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()
getMaxExecutionDelayMillis()
The
JobService
subclass that will be called back by theJobScheduler
to execute the job—getService()
Job arguments:
getExtras()
Retry policy:
getInitialBackoffMillis()
andgetBackoffPolicy()
Okay...