Dear All,
willing to program a software for my little daugther I am facing the following problem: My kid always manages to send my app to the background. She does not know what she is doing, thus presses all buttons including 'back' and 'home'. Aware of the fact that this drains the battery I want my B4A application to stay upfront no matter what happens.
Therefore I tried two ways:
(1) In the Main activity:
Sub Activity_Pause (UserClosed As Boolean)
StartActivity(Me)
End Sub
(2) In the Starter service:
Sub Process_Globals
Dim myWatchdogTimer As Timer
Dim KeepServiceRunning As Boolean = True
End Sub
Sub Service_Create
myWatchdogTimer.Initialize("CheckMainForeground", 300)
myWatchdogTimer.Enabled = True
End Sub
Sub CheckMainForeground_Tick
If KeepServiceRunning = True And IsPaused(Main) Then StartActivity(Main)
End Sub
Both ways work well with the back button, however when I press the home button it takes seconds to bring back my application to foreground. Enough time for my kid to do other weird thing to my phone.
I am sure there is a better way to force the activity to stay. By any chance, maybe without having to restart the main activity each time? And yes, it would be ideal if the screen stayed always-on...
Many thanks for your help in advance,
Christian
willing to program a software for my little daugther I am facing the following problem: My kid always manages to send my app to the background. She does not know what she is doing, thus presses all buttons including 'back' and 'home'. Aware of the fact that this drains the battery I want my B4A application to stay upfront no matter what happens.
Therefore I tried two ways:
(1) In the Main activity:
Sub Activity_Pause (UserClosed As Boolean)
StartActivity(Me)
End Sub
(2) In the Starter service:
Sub Process_Globals
Dim myWatchdogTimer As Timer
Dim KeepServiceRunning As Boolean = True
End Sub
Sub Service_Create
myWatchdogTimer.Initialize("CheckMainForeground", 300)
myWatchdogTimer.Enabled = True
End Sub
Sub CheckMainForeground_Tick
If KeepServiceRunning = True And IsPaused(Main) Then StartActivity(Main)
End Sub
Both ways work well with the back button, however when I press the home button it takes seconds to bring back my application to foreground. Enough time for my kid to do other weird thing to my phone.
I am sure there is a better way to force the activity to stay. By any chance, maybe without having to restart the main activity each time? And yes, it would be ideal if the screen stayed always-on...
Many thanks for your help in advance,
Christian