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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With