The JobScheduler API was introduced in Android 5.0 Lollipop. Its purpose is to let you send requests for processing jobs in a service, but to allow the application framework to decide exactly when the job will be executed. Create a service class that encapsulates the code to execute your task. Schedule the job, and provide a set of constraints that the system uses to determine when the job can be executed.
- [Instructor] The JobScheduler API…was introduced in Android 5.0 Lollipop.…Its purpose is to let you send requests…for processing jobs in a service,…but to allow the application framework, the system,…to decide exactly when the job will be executed.…You'll create a job and then request the scheduling…and you'll pass in what are known as constraints,…a set of rules for when the job should be executed.…These constraints can include things like…when is the network available or a certain timeframe…and then the system decides when to execute it,…keeping in mind priorities…from other jobs from other applications.…
Your service class encapsulates the task itself…so you put all the code to run the task in the service class…and then from your user interface, you schedule the job.…The service will then be created for you,…the code will be executed,…and you'll have an opportunity to send information…back to the UI using broadcast messages…the same way you do with other kinds of services.…The JobScheduler API…lets you separate your code very cleanly.…
First, discover how to create and start simple background threads, and how to use handlers to manage a thread's message queue. Then, learn various methods for optimizing the scheduling and performance of background tasks in Android with AsyncTask, intent services, and the JobScheduler API. Plus, explore tools that help you implement multithreading for different tasks in Android: Loader, for asynchronous data loading, and the open-source API Retrofit, for making HTTP requests.
Note: To get the most out of this course, you should be comfortable programming with Java, and should understand the most basic skills that are needed to build Android apps with the Android SDK and Android Studio.
- Creating and running a background thread
- Sending messages to the UI from threads
- Managing multiple background threads
- Managing threads with AsyncTask
- Managing long-running tasks with services
- Scheduling background tasks with JobScheduler
- Using other APIs for concurrent programming