Sign in to follow this  
CWIPRE

Monogame Xamarin Back Button Fun?

Recommended Posts

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.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this