In this chapter, we learned to schedule work for our applications to perform at some time in the distant future, either as a one-shot operation or at regular intervals.
We learned to set alarms relative to the system clock or real time, how to wake the device up from a deep sleep and doze mode, how to cancel alarms when we no longer need them, and how to set exact alarms on the most recent Android versions.
In the meantime, we introduced the reader to Doze Mode, a new power management feature that saves battery cycles by deferring jobs and tasks to a maintenance window. We learned how to test our alarms taking into account the new power management states introduced by the doze mode.
We learned how to debug alarms created with AlarmManager
and how to analyze the information printed from the dumpsys
commands.
Our exploration covered various options for responding to alarms, including bringing an Activity
to the foreground or doing work directly in a BroadcastReceiver
, synchronously or...