Android Question Screen always on

konisek

Member
Licensed User
Longtime User
How to keep the screen always on during running my app?
Before I used
B4X: Copy
    Dim pw As PhoneWakeState
    pw.KeepAlive(True) 'Display on, bright
 
How to keep the screen always on during running my app?
Before I used
B4X: Copy
    Dim pw As PhoneWakeState
    pw.KeepAlive(True) 'Display on, bright

It should still work. It works for me!

Just make sure that "pw.KeepAlive(True)" is placed in Activity_Create
 
Last edited:
Upvote 0
Also works for me here with Android 14. One thing that has never worked for me is the direct switching between dimmed and undimmed wakelock:
B4X: Copy
Dim pw As PhoneWakeState
pw.KeepAlive(True) ‘Display on, bright
then later at some point: (and this does not work!)
B4X: Copy
pw.KeepAlive(False) ‘Display on, dimmed
To make it work, you have to release the wakelock first. So the correct code is:
B4X: Copy
pw.ReleaseKeepAlive
pw.KeepAlive(False) ‘Display on, dimmed
 
Upvote 0
Back
Top