Reputation: 681
I'm new to Android programming and I am making a game. My problem is dealing with multiple activities on the stack. So I have a gameOver Activity that I call when my player dies. From this activity, I want to return to the main menu on hitting the back button. The problem now is that when I go back to the main menu, and click back again, it goes back to the gameover screen. Do I have to override on back in the main menu to end the application? Or is there a better way to do this?
Upvotes: 1
Views: 409
Reputation: 6311
Typically if you want an activity removed from the history stack you call finish()
The thing is, unless the "Game Over" started the main menu it should not go back to anything other than out of the game when you press back from the main activity, how many screens and how are you getting to each one
Main calls startActivityForResult(new Intent(A,My.class),IntentID); MyClass calls etc.
Upvotes: 1