The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.


JobScheduler

AlarmManager was our original solution for doing work on a periodic basis. However, AlarmManager can readily be misused, in ways that impact the battery — this is why API Level 19 put renewed emphasis on “inexact” alarm schedules. Worse, AlarmManager will give us control at points in time that may be useless to us, such as giving us control when there is no Internet access, when the point of the scheduled work is to transfer some data over the Internet.

Android 5.0 introduced JobScheduler, which offers a more sophisticated API for handling these sorts of scenarios. This chapter will explore how to set up JobScheduler and use it for one-off and periodic work.

Prerequisites

Understanding this chapter requires that you have read the core chapters, particularly the chapter on AlarmManager. Also, you should have read the chapter on PowerManager and wakelocks.

The Limitations of AlarmManager

AlarmManager does its job, and frequently does it well. However, it is far from perfect:

And so on. AlarmManager is nice, but it would be better to have another solution.

Enter the JobScheduler

The preview of this section was stepped on by Godzilla.

Employing JobScheduler

The preview of this section was lost in the sofa cushions.

Pondering Backoff Criteria

The preview of this section was lost in the sofa cushions.

Other JobScheduler Features

The preview of this section is in the process of being translated from its native Klingon.

JobScheduler Period Limits

The preview of this section was the victim of a MITM ('Martian in the middle') attack.

GcmNetworkManager

The preview of this section left for Hollywood to appear in a reality TV show.

Periodic Work, Across Device Versions

The preview of this section is [REDACTED].

Android 6.0 and “the War on Background Processing”

The preview of this section was lost due to a rupture in the space-time continuum.

Scheduling Content Monitoring

The preview of this section left for Hollywood to appear in a reality TV show.