Where's the Back Button and How Do I Use It?

how do I access the Back button.

I am have my activity:

public class Activity1 : Microsoft.Xna.Framework.AndroidGameActivity
    {
        MainGame game;
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);     
            MainGame.Activity = this;

            Vibrator v = (Vibrator)GetSystemService(Context.VibratorService);

            game = new MainGame (v);
            SetContentView(game.Window);
            game.Run();
        }



        public override void OnBackPressed()
        {
            base.OnBackPressed();

           game.BackButton(); // do stuff
        }
    }

OnBackPressed() is never triggered.

I’ll have a lookmat this. However I dont know what is the standard behaviour in Android. Is it just like on WP or is it more like “leave this app”?

Hey @Nezz I wonder if you have any update on this? I am also having a similar issue. On WP when the player taps the back button on the device, my game will display a menu to double confirm if the player wants to exit the game. I was expecting the same behavior to be available on MG Android. However it turns out not. Tapping the back button on an Androi device will put the game to background and brings up the home screen. :expressionless:

It works properly for me. No need for any extra code, it will work the WP-way (using GamePad). Maybe you are missing some declarations from the Activity attribute? These have to be there for sure:

ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize

Those declarations are already in there by default…

I was using Button.Back for the back button on the WP version of my game. And now when I press the back button on an Android device, the game will hide in background… I have no idea how to overwrite the back button behavior… :frowning: