I'll quickly explain how I do it, and for me it worked out so far without problems on both desktop and Android.
First of all I use an AssetManager
for all my assets, including Texture
. I usually load all my assets before entering the actual gameplay screen via a loading screen. But it should also work when you load them in your Screen.show()
method.
Whenever I need an asset, the only way I retrieve them is via AssetManager.get(...)
. My AssetManager
is actually a public static
member of the base game class, so it can be accessed from anywhere in my code and there is only a single one of them.
In my Screen.resume()
method I put an AssetManager.finishLoading()
, though I'm not sure this is really necessary.
Right after the game starts and your AssetManager
is instantiated, I call the static method Texture.setAssetManager(...)
.
This closes the circle. When on Android your OGL context is lost, LibGDX will actually revive it for you. Since you've set the AssetManager
for your Textures
, the manager will be able to find the textures after they have been reloaded. The AssetManager.finishLoading()
will wait until the reloading has been finished. After that, everything should work as before the context loss.
Why Screen.resume()
is not called, I cannot say. For me it is called on Android. Maybe you need to update your LibGDX version.