Hi All,
This is my first post here. I’ve been working in C# for many years, but I am relatively new to MonoGame, and am even newer to Android development, with no prior XNA background.
I recently started playing with a simple game and tried deploying it to Android. It works just fine, but I noticed that if I use the BACK button to exit the game, it remains as a background task. This is fine, but when I go to resume the game, instead of the game relaunching, my phone doesn’t seem to respond. If I use the HOME button instead and resume, it works fine, going back to where the game left off.
I tried the same thing with just a skeleton project with just the light blue screen, and had the same results.
When stepping through the code, I do get an OnStart() call, but then get an OnStop() call, which allows for a brief flash, with the same end result, the game closes and remains a background task. The only way I can get it to run properly is to close/terminate it and start over.
When researching this I found several articles that sounded similar, but they did not solve my problem.
I’m using VS2015 Community, MonoGame 3.6, and I’m using a LG G3 with Marshmallow 6.0 to test it.
So here are my questions:
-
When you click the BACK button to close your Android game, what is the preferred way to handle restoring/restarting your game. Again, the HOME button works fine for restoring it where it was.
-
Is there Xamarin or Android specific stuff that needs to be done - added resources, system calls, etc., or should this behavior be self-contained in MonoGame’s API wrappers.
-
I stepped though the code to see what was happening and saw that in MonoGame.Framework.Android -> Game.cs -> Exit() sets a private field “_shouldExit” to true, but I did not see a way to reset this value. If I go in and manually set this to false after the fact, the simple games seems to resume properly.
so…
a) Should should there be a public way to reset this field along with “_suppressDraw,” or
b) Should the fields be protected so a derived class COULD override them, or
c) Is there a “proper” way I just don’t know yet for how this should be handled.
I would think this is common, so I’m probably just in learning mode, but I would appreciate any suggestions or help.
Thank you,
Derek