Wakelock, deep sleep and gcm

I searched a bit, but asked a question about the true wakelock function with GCM.

Does wakelock really prevent the device from entering sleep mode, which prevents the network layer from shutting down, so it can receive a GCM message from the network layer first

Or, when GCM is up and running (through manifest permissions, correctly encoded GCM code, etc.), it will have a network connection to Google for GCM regardless of whether wakelock is only required from the user interface or application level to enable on the screen again so that you can do other things (interact with the user, etc.) after receiving it.

Or not / some of the above (please specify :)

Thanks Geremy

+4
source share
1 answer

For me, you need to purchase WAKE_LOCK to start the GCM Service , and then release it, since your processor should not sleep before starting the service.

The CPU goes into sleep mode some time after the screen turns off. When your device is in sleep mode, your threads will be suspended.

If you acquired a tracking lock and did not release it, it probably consumes a huge amount of battery.

You can receive GCM messages while your device is in standby mode.

When a message arrives, it depends on your code whether to wake up the device and show a notification or not.

You can also delay the message until the device exits the standby state using the delay_while_idle flag.

You can process messages by registering BroadcastReceiver

Please refer to the SO questions and answers:

Wakelak in deep sleep

Power management

GCM Standby

WAKE_LOCK

0
source

Source: https://habr.com/ru/post/1495657/


All Articles