1

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?

Athos
  • 681
  • 2
  • 7
  • 14
  • noHistory attribute in the manifest comes to mind – Blundell Jul 09 '11 at 21:28
  • Did you override `onBackPressed()` to forward to your Main menu activity? If you did not call `super.onBackPressed()` then the GameOver activity is not finishing, which is why it's still on the stack. – dmon Jul 10 '11 at 00:11

1 Answers1

1

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.

Idistic
  • 6,281
  • 2
  • 28
  • 38