Android Question Turn screen off (and back on) programmatically

jdonth

Member
Licensed User
Longtime User
I am working on a kiosk application and I would like to be able to turn the screen completely off after a specific time interval (rather than set brightness to 0). I know that it will (I assume?) also disable the screen touch events, but I am using OpenCV with the camera to "wake up" the app with motion. If this is possible? If so, I also need to know how the turn the screen back on. Thoughts?
 

Marcos Alves

Well-Known Member
Licensed User
Longtime User
Hi @Erel ... I noticed that in some SoftPhone apps the screen is automatically turned off when the proximity sensor detects the user near the screen (off course... to avoid the user face touching the screen hangs up the call or does mistaken touches).
How can we do the same?
 
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
As I said there is no public API in Android to turn off the screen.
Hello @Erel . Thanks for answering. But I still have a doubt: if there is no public API to turn off the screen, how do whatsapp and many others phone calls apps turn off the screen using the proximity sensor data? See, when you are in a phone call using this apps the behavior is similar when in a traditional mobile network call: if any object is detected nearest than, lest say, 10 centimeters from screen, it's automatically turned off and remains in this state until the detected object is removed or call finishes. How do they do this? I thought that could be a "black panel with alpha 255" over the entire screen but doesn't looks to be: it looks that the screen is really turned off. So, considering that you told that there is no public API to do this, how did they do?
 
Upvote 0
Top