Android black textures on resume

Check this weird issue that came up recently on my second go at porting a WP app to Android (no problems with first port months ago). To best illustrate it, I came up with a simple way to reproduce it:

  1. create a new solution with a project MonoGame for Android.

  2. deploy to device and run it, then press the home button and resume the app again. You will see that all is well and the “Hello from MonoGame” draws fine.

  3. now add the following to LoadContent()

    x = new Texture2D(graphics.GraphicsDevice, 1, 1);
    x.SetData(new[] { Color.Pink });
    graphics.GraphicsDevice.DeviceReset += (sender, args) =>
    x = new Texture2D(graphics.GraphicsDevice, 1, 1);
    x.SetData(new[] { Color.Pink });

  4. add  spriteBatch.Draw(x, new Rectangle(10, 100, 300, 300), Color.White); after spritebatch.Begin(). followed by the default monogame hello draw.

  5. now launch the app, deactivate it and launch it again (resume)

You will see that both are now black. This issue is new and didnt occur when I used MonoGame months ago for my first port. Please help me fix this issue since its the only thing holding me from release.

On Android and Windows Phone 8 the graphic context is lost on resume, which means that all textures will be lost. MonoGame automatically reloads all content loaded via ContentManager. We have hooked up the restoration to the activated event and it works well.

Does GraphicsDevice.Reset occur at all? Is the drawn texture black before resume?

This doesn’t happen in WP8 for me. I assumed that NuGet will always have the latest and greatest version but it seems not, because after reading this thread, I downloaded the Github developer branch as a zip and built the android solution (release mode Any CPU) and referenced those dll instead and the problem is solved. I preferred using NuGet in WP8 since it resolved the ambiguous reference problem which I wasnt able to resolve myself, but on Android it seems better to avoid NuGet for now.