Important Points of Doze mode
What is Doze mode?
Doze mode is a feature in Marshmallow, which prevents certain tasks from running if your device is in idle state. Doze in devices reduces power consumption by deferring background CPU and Network activity for applications.
What is Maintenance Window?
Periodically, the system exits Doze for a brief time to let apps complete their deferred activities. This time is called Maintenance Window.
During this maintenance window, the system runs all pending syncs, jobs, and alarms, and lets apps access the network.
At the conclusion of each maintenance window, the system again enters Doze, suspending network access and deferring jobs, syncs, and alarms. Over time, the system schedules maintenance windows less and less frequently, helping to reduce battery consumption in cases of longer-term inactivity when the device is not connected to a charger.
Doze restrictions
- Network access is suspended.
- The system ignores wake locks.
- Standard
AlarmManager
alarms (includingsetExact()
andsetWindow()
) are deferred to the next maintenance window. - The system does not perform Wi-Fi scans.
- The system does not allow sync adapters to run.
- The system does not allow
JobScheduler
to run.
How to do network call in Doze mode?
- If your users must see a notification right away, make sure to use an FCM high priority message.
- Set critical alarms with
setAndAllowWhileIdle()
andsetExactAndAllowWhileIdle()
.
Note: Neither
setAndAllowWhileIdle()
norsetExactAndAllowWhileIdle()
can fire alarms more than once per 9 minutes, per app.
App Standby
If the device is idle for long periods of time, the system allows idle apps network access around once a day.