Monogame Xamarin Back Button Fun?

Started by
-1 comments, last by CWIPRE 9 years, 7 months ago

So I've made a game. It works great on my phone and on emulators. It even closes properly. So to complete the package I'm trying to give the back button the functionality the user would expect. But FML.

I start with:


    public class Activity1 : Microsoft.Xna.Framework.AndroidGameActivity
    {
        TempleMain game;


        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);  


            TempleMain.Activity = this;


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


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

and throw in


        public override void OnBackPressed()
        {
            base.OnBackPressed();
            if (game != null)
                game.BackButton();
        }

Nada.

Now, I'm thinking that AndroidGameActivity inherits from Androids Activity yet does not override Activity's OnBackPressed() thus not giving me proper access????....

Am I using activities wrong? Game compiles and runs just fine. And the home button does what you would expect without my help.

This topic is closed to new replies.

Advertisement