Android Question (Solved) KeepAlive with multiple Activities

MikeSimpson

Member
Licensed User
Longtime User
I am building an app with multiple Activities and don't want the phone to go to sleep when the app is active.

If I use:
B4X:
Dim Awake As PhoneWakeState

Sub Activity_Create(FirstTime As Boolean)
Awake.KeepAlive(True)

in the main activity, it is working, but the phone stays alive also after I ended the app. So I have to use:
B4X:
Sub Activity_Pause (UserClosed As Boolean)
Awake.ReleaseKeepAlive
End Sub
to kill KeepAlive.

But then the phone keeps going to sleep, if I call another activity.

Do I have to use
B4X:
Awake.KeepAlive(True)
and
Awake.ReleaseKeepAlive
in every activity or is there a way to call "ReleaseKeepAlive" when I exit an app, not only when I end an activity?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…