Notes: 23. Introduction
The student materials have been reviewed and are updated as of SEPTEMBER 2022.
Good job reaching the last part of this course! :]
You’ve learned a lot about the modern ways of working with background processing in Android and scheduling work. You’re now ready to tackle any use cases you might have in your future applications!
But sometimes you have to work on older projects. It helps knowing where all the newer APIs come from, and what used to be the tools for background processing.
In the last part of the course, you’ll build an AsyncTask, use the JobScheduler and the AlarmManager.
One of the first APIs in Android was the AlarmManager API. With it, you can schedule work at an exact or approximate time. Note that the AlarmManager is not used for background processing directly. It’s used to schedule alarms which notify other Android components to launch some work.
After the AlarmManager came the AsyncTask. It’s the first wholesome API, which handles threading out of the box. It can also give you the task progress for you to display on the UI.
After the AsyncTask came the JobScheduler API. It’s meant to be easier to use, and safer when it comes to resource management. The idea is to create Jobs, with specific conditions, and a specific amount of time it needs to start in, or a deadline. In that way, you’re trying to produce a result in a fixed amount of time.
The JobScheduler relies on JobServices, a service similar to the IntentService. Within the service, you have to define your business logic, and offload the work to a background thread yourself. You also need to notify the service when the Job is finished, by calling jobFinished from within.
That is quite a lot to cover, in only a few episodes!
You’ll get a good understanding of each of these concepts, and I think you’ll see why some of the newer APIs are the preferred way of processing work in the background, nowadays.