Turn the screen in to totally dark when press the

2019-09-17 22:22发布

问题:

How to code the android to turn the screen completely off just like you press the power button to lock your screen.

I want the user to press the button on the screen and then screen goes off.

I have tried (with permission):

PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag");

wl.acquire();

but not working for me, please help! thank you!