How to use PowerManager.ACQUIRE_CAUSES_WAKEUP

2k views Asked by At

How can I use ACQUIRE_CAUSES_WAKEUP? ACQUIRE_CAUSES_WAKEUP must be used with another wakelock or you risk an error:

 java.lang.IllegalArgumentException: Must specify a valid wake lock level.

However, FULL_WAKE_LOCK, SCREEN_DIM_WAKE_LOCK, and SCREEN_BRIGHT_WAKE_LOCK are all deprecated, and ACQUIRE_CAUSES_WAKEUP doesn't work with PARTIAL_WAKE_LOCK

"Cannot be used with PARTIAL_WAKE_LOCK."

docs

So does that mean that ACQUIRE_CAUSES_WAKEUP is effectively useless?

1

There are 1 answers

1
AlexS On

You can use it like this:

PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock screenWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,
                TAG);