I google this and there is a lot of examples in handling the even on_screen_of and on_screen_off, but I want to actually turn on and turn off the screen. Every search I made it lead me on handling the screen on and off event.
I want to have a button that when clicked will turn the screen off.
How can I do this, and what permissions do I need ? or I this is talked before please give me some useful link
Thanks
PowerManager manager = (PowerManager) getSystemService(Context.POWER_SERVICE);
manager.goToSleep(int amountOfTime);
You will probably need this permission too:
<uses-permission android:name="android.permission.WAKE_LOCK" />
Answer extracted from here
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