Challenge: Using JobService on Lollipop

For an additional challenge, create a second implementation of PollService that subclasses JobService and is run using JobScheduler. In your PollService startup code, check to see whether you are on Lollipop. If so, use JobScheduler to schedule your JobService. Otherwise, fall back on your old AlarmManager implementation.

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.