3

I created a game in with LibGDX, which works fine on my computer. I created a debug .apk in Android Studio 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.

If anyone could help?

Rik van Velzen
  • 1,977
  • 1
  • 19
  • 37

1 Answers1

3

The difference in your use cases is the state of the JVM that is running your application. In some cases the JVM is brand new, and everything works. However, if the JVM is recycled (because Android hasn't killed it, just put it in the background), you run into problems. The core of the problem is, most likely, that you have references to OpenGL state from the previous run when you re-start the application (e.g., OpenGL texture IDs from the first run are getting used on subsequent runs). Because OpenGL is a stateful driver, and an application's state is wiped when it loses context, you need to reload global OpenGL state.

See Android static object lifecycle for a description of the underlying problem and http://bitiotic.com/blog/2013/05/23/libgdx-and-android-application-lifecycle/ for some Libgdx-specific tips on diagnosing and dealing with it.

Community
  • 1
  • 1
P.T.
  • 24,557
  • 7
  • 64
  • 95