I need to programmatically turn the screen on when the user turns off with power button, and yes I always have the correct flags in the Activity
to keep screen on, but it does not avoid user pressing power button.
So far I've found a solution but it uses a deprecated wakelock
sWakeLock = sPM.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, TAG_WAKELOCK);
sWakeLock.acquire();
sWakeLock.release();
There is a better way to achieve it?