Android / LibGDX: Images disappear after i start my debug .apk from widget

Hi,

I created a game, which works fine on my computer.
I created a debug .apk in Android Studiuo via the Gradle View -> Build & then copied my android-debug.apk & android-debug-unaligned.apk to the download folder of my Android Device.

Now when on my android device I clicked on one of my files the device ask if I wanna install it and choose yes and subsequently I open my game and it run fine.

Now the porblem occurs when i quite the game and try to restart the game from the widget that after the installation has been put on my android-“desktop” (main screen with all the apps you can click).

If i start it from the widget my graphics are messed up and missing & i have no idea why?
Logo image missing from splashscreen. When switching to MenuScreen the image there is missing. And when I switch to my game screen graphics get totally messed up.

When i re-install the game and run it again, there is no problem.

Anyone?

Context loss.

If you are using static fields for assets, now is the time to stop. Have a look at AssetManager for an easy to use asset cache.

Also if you are disposing of assets, stop it. Unless you are 100% sure you won’t ever need them again, never dispose of them, the garbage collector will hate you for it.

If you don’t want to use AssetMananger, simply having a reload assets method that re-loads all the assets from internal storage after the app resumes is usually enough. If you have a lot of stuff to load, be prepared for a nice black loading screen for x amount of time.

That’s probably it Gibbo.
I was already wondering why people were so against using static fields cause it worked so convenient for me (untill now ^_^) to store all assets in one class and just be able to call them when needed with a static import.

And yes, I also have been adding everything that’s disposable to my dispose methods:
All the tutorials I went through i always see instructors telling things like: “make sure you dispose the spritebatch or the texture in the dispose method”.

Gonna change these things today and see if it’ll work

Yeah, a lot of people do that. I really don’t get why, you rarely use enough of such things to grant them needing to be disposed. You usually have a Spritebatch or 2 and they are usually used in ever game state, like the menu and loading screen. Textures get loaded once, then you just transform them before drawing them.

1 Texture, many Sprites.

So now i changed my code and load my textures in the constructor, like:

	
	public Texture UI = new Texture("pacmanbow_ui_UP_800x480.png");
	public Texture BUTTONLEFT = new Texture("button_left_150x119.png");
	public Texture BUTTONUP = new Texture("button_up_150x119.png");

etc.

But now when i test my app on my android device the sizes of my textures get messed up (twice as big). And all graphics gets messed up.

My TiledMap that I am rendering with libGDX’s tilemapRenderer get’s displayed ok though.
It seems as if everything else gets scaled up by a factor 2 except for the tilemaprendering (which doesnt make sense to me)

Created a post here and on stackoverflow, but no responds yet.

Any idea how to fix this?