Summary
In this chapter, we explored the JobSheduler
API, putting it to use to schedule background work that starts when a group of conditions defined by us are met.
We learned in detail how to set the different criteria supported by the API and how to schedule based on the JobInfo
object that starts a job when the device is charging and not in use.
In the meantime, we learned how to implement an asynchronous JobService
that is able to run in a background execution line and finish the job execution properly by releasing all the acquired resources (WakeLock
, ...
).
Later, we used the getAllPendingJobs
to create a sample code to list all the pending Scheduler API jobs within our application. From the example, we learned how to cancel a specific job or all the pending jobs in our applications.
To finish, we built a persistent and recurrent schedule using the JobSheduler
API, which wakes up the device and executes our job every 12 hours.
In the next chapter, we will learn how to transfer data from...