I have an application running in the device. If I press home key and then return to the app by pressing the multitask button, the app keeps running where I left it.
But, if I press home key and then I press the app icon the app restarts, even entering in main_activity_create.
What's happening? How can I avoid this restarting?
Hi all, just manage to find this topic. I'm having the same issue. I thought my app has problem but I try using "Two activities" app in the tutorial. It also has same issue. So what is the conclusion? Many app, especially games, when you are playing.If you press HOME key and re-run the app again by clicking the icon, it still shows the game you were playing, not restart everything, how do they do it?
I've been having a similar problem, I tried Avansys's solution:
B4X:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime = False Then
Activity.Finish
Else
do something....
End If
End Sub
But what I'm finding is that after I actually close my app with the back button
B4X:
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed = True Then
CallSub2(Unit_Comms, "KillUnit", "Main")
Awake.ReleaseKeepAlive
End If
End Sub
And try start the app from the icon again, it closes right away - FirstTime = False is being reported in the log window.
Is this because my service is still running?
Update. I added an ExitApplication to the main's Pause fuction, and now all appears to be working OK. On droid 6.0.1. Off to test on 5 and 4.4 now.
This seems to be the only way I can get it to work, is it OK to use ExitApplication?
B4X:
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed = True Then
CallSub2(Unit_Comms, "KillUnit", "Main")
Awake.ReleaseKeepAlive
ExitApplication
End If
End Sub