01 octobre 2015
Posted by, Laurence Moroney, Developer Advocate
Android 6.0 Marshmallow introduces a new power saving feature called ‘Doze’. A device enters Doze when the user leaves it unplugged and stationary for a period of time and with the screen off. When this happens, the system defers application activity to save power. It will periodically and briefly resume normal operations, called an idle maintenance window, in order to perform app syncing and other pending operations.
If your app uses Google Cloud Messaging (GCM), you will need to take into account the following behaviors for users whose devices are in Doze.
GCM has two priority types for messages, called high priority and normal priority. When using high priority, GCM attempts to deliver messages immediately, waking a device in Doze, as needed. With Android Marshmallow, nothing changes here.
However, when using normal priority (the default priority), there are a number of different behaviors when the device is in Doze, including:
Despite this, it is recommended that, unless absolutely necessary, you keep your notifications as normal priority ones, as this will minimize battery impact. They will still sync during doze mode as described above, and of course once the device exits Doze.
High priority messages should only be used by applications that need to generate an immediate notification to the end user such as a chat app notification or an incoming phone call.
To learn more about Google Cloud Messaging message priorities, visit the Google Developers site.