Android Question How to turn off the screen(SCREEN_OFF)?

20353841

Member
Licensed User
Longtime User
How to turn the back screen power off?I only searched the forum about detecting SCREEN_ OFF.
 

peacemaker

Expert
Licensed User
Longtime User
Search for "WAKE_LOCK", PhoneWakeState


B4X:
AddPermission(android.permission.WAKE_LOCK)
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
If you talk about the programmatic screen off like by the hardware switch - it's impossible, IMHO.
PhoneWakeState is about switching off the backlight variant.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
can not turn screen power off
Recent years and Android versions Google has limited the programmatic actions that may concern the security, private data access and so on.
It's easy to imagine: if some action is dangerous to "hack" the phone (switch on-off, delete info, send SPAM, discharge battery...) - it's already forbidden on non-rooted device, and impossible :)
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Firstly for any question - just try to search the forum for the key words, like "proximity sensor".
And also Google search engine can help.
 
Upvote 0

GJREDITOR

Member
oh sure I already tried for 2 days so far, the "proximity sensor" is a sensor so its read not write, I mean you can find out if the user put the phone to his ear but you need some code to lock the display
You may have to use device-administrator-library: https://www.b4x.com/android/forum/threads/device-administrator-library.19208/ Lock Screen app in Play Store too uses the administrator library:
lock screen shot.jpg

If you need to change the Screen brightness alone, you can check : https://www.b4x.com/android/forum/threads/change-brightness-without-permissions.148162/#post-939122
 
Last edited:
Upvote 1
Top