I would like to unlock screen and switching it on to show a popup on an event trigger. I am able to unlock the screen using
newKeyguardLock = km.newKeyguardLock(HANDSFREE); newKeyguardLock.disableKeyguard();
on KeyGuardService
but I cannot turn on the screen. I am using
wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, HANDSFREE); wl.acquire();
but with no success. The screen still remains off. How can I achieve this?
Method #1: Enable the double-tap gesture to turn on the phone screen. One of the easiest and quickest ways to turn on your Android phone's screen without using the power button is by enabling the double-tap gesture in settings.
Note from author: I wrote this back in 2012. I don't know if it works anymore. Be sure to check out the other more recent answers.
Amir's answer got me close, but you need the ACQUIRE_CAUSES_WAKEUP
flag at least (Building against Android 2.3.3).
WakeLock screenLock = ((PowerManager)getSystemService(POWER_SERVICE)).newWakeLock( PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG"); screenLock.acquire(); //later screenLock.release();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With