For the More Curious: JobScheduler and JobServices

In this chapter, you saw how to use AlarmManager, an IntentService, and PendingIntents to stitch together a periodically executing background task. In doing that, you had to do a few things manually:

  • schedule a periodic task

  • check whether that periodic task is currently running

  • check whether the network is currently up

You might want to do more than that in the real world. For example, you might want to implement a backoff-and-retry policy if your request fails, or restrict network access to unmetered Internet access. What if you wanted to only check for new photos while the device was charging? These things are certainly possible, but they are not easy or obvious.

On top ...

Get Android Programming: The Big Nerd Ranch Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.