0

I used Wakelock in my application for fire CPU on when the device went to sleep but i don't want to turn on when screen is off, i mean, i want to keep state of screen and just turn on cpu for my background works. I used below code but in some of devices, in wakelock device, the screen was turn on but as i readed about PowerManager and i realised, i had to used just PARTIAL_WAKE_LOCK. Is that true?

before code:

wakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK
            | PowerManager.ACQUIRE_CAUSES_WAKEUP
            | PowerManager.ON_AFTER_RELEASE,"aqs_wake_lock");

after edit:

  wakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"aqs_wake_lock");
Fahim
  • 384
  • 5
  • 20

1 Answers1

0

A wake lock is a mechanism to indicate that your application needs to have the device stay on

PowerManager defines various types of wakelocks The following wake lock levels are defined, with varying effects on system power. These levels are mutually exclusive - you may only specify one of them.

enter image description here

As you can see from the picture partial wakelocks will continue to run irrespective of state of screen.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Androider
  • 3,833
  • 2
  • 14
  • 24