Hi developers
I am working with 2 activities but am trying to figure a good way of closing the app from the "main" activity without the second activity re-appearing
Lets assume two activities are created:
main
activity2
I want the "BACK" button to act as an app quit, closing everything, but only when in the "main" activity
When in "activity2" the back button should act as a 'go back to main activity'
At the moment I use StartActivity() to bounce between the two. I am not trapping the BACK key
The thing with this method is, when you press BACK from the "main" activity the "activity2" will appear. This makes sense in that the "main" has been killed (leaving "activity2" to fend for itself)
I tried using a flag within Resume() of "activity2" so it would know that the main activity had closed. You still get to see the activity before things close so it kind of looks a little buggy or ugly
Ideally I would like to do something like this
Code:
' "main" activity
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed=True Then activity2.Finish
End Sub
The problem is, activity2 cannot be accessed in this context
So, I could trap the BACK key, although I attempted this before and got stuck in a whole world of mess whereby I could not quit at all(!)
Another option is to hide activity2 contents when leaving and show them upon entering again. This could be done but right now everything is parented to the activity. Also the background is a gradient
Possible I could LoadLayout() and load up a blank template
My final option is to call Activity.Finish whenever I leave Activity2
This I find gives a slight delay though when going back into the activity because it needs to be re-created again
Your thoughts?