Android Question disable auto sleep

Almog

Active Member
Licensed User
Hi

I need that when my app in open the phone will not turn of automaticly(after a few
minutes) and stay logged on.

does someone knows how can I do that?

Thanks
 

Almog

Active Member
Licensed User
OK, its written that I need to write PhoneWakeState.KeepAlive in the phone library,
I am new to b4a, you can please explain how can i do that?

thanks
 
Upvote 0

BillMeyer

Well-Known Member
Licensed User
Longtime User
Ok - in this forum, the rules are that you try something on your own first and then when you hit a snag, we will try and help. If you do not do this you will end up not learning, but always relying on others to achieve your goals.

This time I am going to break the rules to get you started.

Firstly, on the right of your IDE, you need to select the Libraries Manager (at the bottom) and then look for the "Phone" Library. Once you have done this the "Phone" library becomes available for use.

Now in your Sub Globals you need to add this
B4X:
    Dim pws As PhoneWakeState

Then, in Sub Activity_Create....., add this

B4X:
Sub Activity_Create(FirstTime As Boolean)
    pws.KeepAlive(True) ' Will keep the phone in wake state with a bright screen
End Sub

My next recommendation - work through these - they will bring you to speed very, very quickly https://www.b4x.com/android/forum/threads/b4x-erel-teaches-programming-video-tutorials.88787/

Enjoy !!
 
Upvote 0
Top