Android Marshmallow 6.0: Introduction to Doze Mode

Android Developers · 98K views · 2015 · 2:52

Open on YouTube

Software (other)Consumer devices & gadgetsexplainerdated

Why Stack Overflow recommends it

Stack Overflow users link it when answering why alarms, background network calls or jobs are delayed on Marshmallow and later, as a quick primer on Doze mode.

Recommended by 3 people across 3 different months, 2015 to 2017.

What it is

A short official Android Developers video introducing Doze mode in Android 6.0 Marshmallow, an idle state the device enters to save battery. It covers the motivation, how apps behave in and out of Doze, and how to keep an app responsive using high priority GCM messages or AlarmManager's ...AndAllowWhileIdle() methods.

What people said

Recommends Konstantin Loginov · 2015-12 · Stack Overflow · on “Android alarm events gets delayed”

In Android 6.0 Marshmallow, Google introduced "Doze" mode. Read more about it here: Optimizing for Doze and App Standby [LINK] And/or watch here: Android Marshmallow 6.0: Introduction to Doze Mode [this video] In your case, Google recommends to use setAndAllowWhileIdle [LINK] which force phone to bypass Doze mode instead set (and setExactAndAllowWhileIdle [LINK] instead of setExact .) NB! It looks like, there's no analogue for setRepeating , so you have to schedule next recurrence "manually" with setExactAndAllowWhileIdle [LINK] , one by one. For devices with Android 4.4 KitKat and above - consider to use setExact [LINK] instead of old set , as the OS tries to shift alarms in order to minimize wa

Recommends Abdalla Elarabi · 2016-05 · Stack Overflow · on “Android alarmmanger gets called in different time?”

This might happen if you are using Android version Marshmallow or higher. It is called Doze Mode Doze Mode is implemented to save the battery by delaying stuff like AlarmManager , SyncAdapter , JobScheduler . Refer to this link [this video] to find out more about Doze Mode

Recommends Xavier Rubio Jansana · 2017-08 · Stack Overflow · on “Geofencing : HTTP request failed while sending through the background service. Gives UnknownHostException”

The explanation by @Stevensen about Doze mode being the reason of the failure is more likely the cause. In the documentation [LINK] you can read: The following restrictions apply to your apps while in Doze: Network access is suspended... I'll suggest to store the events in a DB, and schedule a job to upload them to the server by using JobScheduler [LINK] (API 21+, see a tutorial here [LINK] ) or, if you need to support older devices, by using this replacement firebase-jobdispatcher [LINK] (which provides a JobScheduler-compatible API by wrapping GCM Network Manager). I'll suggest to set a condition of network is needed: .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) and probably a .setPer