4

I've searched a bit but had a question about the true function of the wakelock with GCM.

Does the wakelock prevent the device from going into a sleep mode that would prevent the network layer from shutting down -- so it can receive a GCM message from the network-level in the first place

Or when GCM is enabled and working (via manifest permissions, properly coded GCM code, etc), it will have a network connection to Google for GCM up regardless, and the wakelock is only needed from a UI or application level to turn the screen back on so you can do other things (interact with user, etc) after receiving it.

Or none/some of the above (please elaborate :)

Thanks geremy

Geremy
  • 2,415
  • 1
  • 23
  • 27

1 Answers1

0

According to me you need to acquire WAKE_LOCK to start GCM Service and then release it, as your CPU should not sleep before starting service.

CPU will go in sleep mode in some time after your screen turns off. When your device is in sleep mode your threads will be suspended.

If you acquire wake lock and does not release it, it will surely consume huge amount of battery.

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

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

You can also delay the message till device comes out of idle state by using a flag delay_while_idle.

You can handle messages by registering BroadcastReceiver

Please refer to the questions and answer on SO :

Wakelock in deep sleep

Power management

GCM in standby

WAKE_LOCK

Community
  • 1
  • 1
Siddhesh
  • 1,370
  • 11
  • 28