In game, images disappear on android device if i run from widget but not when i install apk for the first time

I created a game using LibGDX which works fine on my computer. I created a debug.apk in Android Studio using Gradle View -> Build and then copied my android-debug.apk and android-debug-unaligned.apk file to the download folder of my android device.

Now when on my android device I clicked on one of my files, the device will ask if I want to install it and select yes, and then I open my game and it works fine.

Now the problem occurs when I am completely playing and trying to restart the game from a widget that, after installation, was placed on my Android "desktop" (home screen with all the apps you can click).

If I run it from the widget, my charts are messed up and gone and I have no idea why? There is no logo image on the pop-up screen. No display when switching to MenuScreen. And when I switch to my graphics, the screen is completely messed up.

When I reinstall the game and run it again, no problem.

If anyone can help?

+3


source to share


1 answer


The differences in your use cases are the state of the JVM that starts your application. In some cases the JVM is brand new and everything works. However, if the JVM gets recycled (since Android didn't kill it, just put it in the background) then you're in trouble. The core of the problem is most likely that you have references to the OpenGL state from a previous run when the application is restarted (for example, OpenGL texture IDs from the first run are used in subsequent runs). Since OpenGL is a stateful driver and the application state is erased when it loses context, you need to reload the global OpenGL state.



See Android Static Object Lifecycle for a description of the underlying issue and http://bitiotic.com/blog/2013/05/23/libgdx-and-android-application-lifecycle/ for some Libgdx specific advice on diagnosing and working with it.

+3


source







All Articles