I still have no idea what’s causing this, but I have discovered a half workaround. By half, I mean it will allow recovery if you task switch while an ad is open, but only if you didn’t click the ad itself (which launches a web browser linked to your main activity).
The general idea is as follows…
- Create a new activity, MainActivity, to serve as a host for the application. This has MainLauncher = true set in the attributes and does not launch the mono game class. Ensure LaunchMode is set to SingleInstance as well.
- Remove MainLauncher = true from your MonoGame Activity… say, MonoGameActivity.
- In MainActivity.OnResume, have it switch to the game activity the first time, but all other times have it just show an Ad.
- In the OnAdClosed method, have it switch to the game activity.
- In the game activity, when it’s time to show an ad, have it change to MainActivity. This will trigger an ad to show and, when that ad closes, it will switch back to the game activity.
Here is the code that makes up my MainActivity class: https://pastebin.com/5GEh73GR
In the Activity1.cs code above, I got rid of all the references to the InterstitialAd object and, in ShowAd, I simply put the following code:
{
Intent i = new Intent(this, typeof(MainActivity));
this.StartActivity(i);
}```
This sort of works, but isn't ideal because you can still get the issue if you click the ad, then task switch back to the game without closing the web browser that was launched. If you close the web browser first, everything comes back fine, but if you leave the browser open, it breaks.
So it's something... at least?