Exit game

Hi,

I used game.Exit method for close the application and it goes to background. When i click icon again, application not start. I’m using monogame 3.6

Any idea?

Thanks

What platform are you putting the game on?

This is in the Android category.

Ahh, my bad! Clearly my attention to detail is failing me miserably… Are you even supposed to use Exit() on mobile? Shouldn’t you just let Android deal with that when the user swipes away the app in the task list?

1 Like

I had some issues with this actually. I dug around the interwebs and found a workaround. I created a GameFinished event on my game class, then do this in my Activity1.OnCreate method.

            _game = new MainGame(container);
            _game.GameFinished +=
                (sender, e) =>
                {
                    Process.KillProcess(Process.MyPid());
                };

This causes the game to actually die so when you click on it again (via the icon or the task list), it will restart.

Thank you Trinith. I’ll try this

NOTE: You actually have to trigger the event from within your game. Sorry, that might not have been clear!