5

I have created a simple game for Android; I want to prevent users from sending the game to the background by pressing the home or back buttons accidentally. I planned on using a dialog to confirm the user's action. What I want is similar to what Sirius does with their app, if you need an illustration.

I tried adding this action to an overridden onPause(), but the activity vanishes right after the dialog is displayed, so I don't think I'm going about this the right way. How can I fix this?

Any help is appreciated.

Sean W.
  • 4,944
  • 8
  • 40
  • 66

1 Answers1

5

You can only override the back button. You cannot override the home button. This is more or less for security reasons (to prevent someone's phone from getting hi-jacked).

See these two questions.

Community
  • 1
  • 1
Bryan Denny
  • 27,363
  • 32
  • 109
  • 125