0

Is there any way we can acquire a Partial wacklock when the device goes into a deep sleep mode without triggering a screen ON?

Acquiring the wakelock seems to work only if the device is awake (screen Off).

I need to keep the screen Off.

Edit: I'm editing my question to share my conclusion, i was looking for a way to wake-up the device from the deep sleep with a partial lock, but i was on the wrong way, my real issue was related to handling the Volume buttons key on deep sleep, it seems impossible since Android does NOT broadcast Volume button events on Deep sleep.

wanam
  • 548
  • 4
  • 8

1 Answers1

1

Is there any way we can acquire a Partial wacklock when the device goes into a deep sleep mode without triggering a screen ON?

Sure. A partial WakeLock does not turn on the screen, by definition.

Acquiring the wakelock seems to work only if the device is awake

Sure. Your code will only run when the CPU is executing instructions.

A WakeLock does not wake up the device. A WakeLock keeps the device awake. A partial WakeLock does that while not turning on the screen.

I need to keep the screen Off.

While you can avoid turning on the screen yourself, by using a partial WakeLock, you cannot prevent other apps from turning on the screen, if they feel it is in their users' interests to do so (e.g., incoming phone calls).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks for the reply. So how can i wakeup the cpu? – wanam Feb 06 '14 at 22:42
  • 1
    @wanam: Well, you need to choose a trigger mechanism. For example, if you want to wake up a particular time, use `AlarmManager` with a `_WAKEUP`-style alarm. That will wake up the device *briefly* and give you control. From there, you can use `WakefulBroadcastReceiver`, my `WakefulIntentService`, or your own `WakeLock` (though I would *strongly* encourage one of the first two options). – CommonsWare Feb 06 '14 at 23:11