Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow dialog to be displayed before or during onPause()?

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.

like image 337
Sean W. Avatar asked Nov 09 '10 01:11

Sean W.


1 Answers

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.

like image 189
Bryan Denny Avatar answered Nov 13 '22 04:11

Bryan Denny