Android Question Activity.Finish - always returns to Main?

Tony Tetley

Member
Licensed User
Longtime User
Main does a StartActivity("A")
Activity A does a StartActivity("B")
if the user presses the back button the focus goes back to Main. How do I get a return to Activity "A" when the back button is pressed in Activity "B"? In other words, how do you return through the call stack?

Thanks,

Tony
 

DonManfred

Expert
Licensed User
Longtime User
Without seeing your code it is hard to give advices.
What are you doing in Activity A when you start B? Are you using Activity.Finish?
 

Attachments

  • threeactivities.zip
    10.4 KB · Views: 255
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
In this 2nd Example it is wanted to go back to main when leaving B.
It is realized with removing Activity A from the backstack when starting activity B
B4X:
Sub Button1_Click
    StartActivity(B)
    Activity.Finish
End Sub
This will start B and then finish Activity A. If you then go back from B you will return in Main, not in A.
 

Attachments

  • threeactivities2.zip
    10.4 KB · Views: 244
Upvote 0

Tony Tetley

Member
Licensed User
Longtime User
Don, thank you for the reply. In your example I removed the Activity.Finish that was with the StartActivity(B) and pressing the back button in B goes back to A. This is the behavior I want. I am not doing an Activity.finish when I start another activity, but I do an Activity.Finish in the Activity_Pause sub. I inserted the Activity.Finish in the A and B Activity_pause in your example and pressing the back button in B returns to Main.

I guess I need to do some more reading/understanding on the activity as I thought I should finish when going back to release the resources.
 
Last edited:
Upvote 0
Top