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.


AlarmManager and the Scheduled Service Pattern

Many applications have the need to get control every so often to do a bit of work. And, many times, those applications need to get control in the background, regardless of what the user may be doing (or not doing) at the time.

The solution, in some cases, is to use AlarmManager, which is roughly akin to cron on Linux and macOS and Scheduled Tasks in Windows. You teach AlarmManager when you want to get control back, and AlarmManager will give you control at that time.

Android 5.0 added a separate JobScheduler. Like AlarmManager, JobScheduler is designed for background work. JobScheduler is more sophisticated than is AlarmManager. For example, if you need an Internet connection to do your work, JobScheduler will only give you control if there is an Internet connection. If your app’s minSdkVersion is 21 or higher, you might consider using JobScheduler instead of AlarmManager. JobScheduler is covered in an upcoming chapter.

Prerequisites

This chapter requires you to have read the core chapters of the book, in particular the chapter on services.

Scenarios

The preview of this section was stepped on by Godzilla.

Options

The preview of this section will not appear here for a while, due to a time machine mishap.

A Simple Example

The preview of this section was last seen in the Bermuda Triangle.

The Five set…() Varieties

The preview of this section is [REDACTED].

The Four Types of Alarms

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

When to Schedule Alarms

The preview of this section was last seen in the Bermuda Triangle.

Archetype: Scheduled Service Polling

The preview of this section is unavailable right now, but if you leave your name and number at the sound of the tone, it might get back to you (BEEEEEEEEEEEEP!).

Warning: Not All Android Devices Play Nice

The preview of this section did not survive Thanos's finger snap.

Debugging Alarms

The preview of this section is presently indisposed.

Android 6.0 and the War on Background Processing

The preview of this section is sleeping in.

Android 7.0 and OnAlarmListener

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