I am using a PowerManager.WakeLock to keep the device from going to sleep automatically during certain states of my app. However, if the user presses the power button, I want the device to power off. Is there a WakeLock flag that can do this? Or is there a notification I can receive when the user presses the power button?
I am using a PowerManager.WakeLock to keep the device from going to sleep automatically
Share
Any
WakeLocktype other thanPARTIAL_WAKE_LOCKwill have this effect. Quoting the documentation:You should only hold a partial
WakeLockfor background work that you want to run to completion (e.g., long file download), then release thatWakeLock.No sorry.