Fold live wallpaper


I have made a live wallpaper for Android. But for Samsung (e.g. Fold3 Android 14) I have the issue that the wallpaper restarts whenever the screen is changed (from cover to outer screen, vice versa). It is an OpenGLES based live wallpaper. And usually some heavy loading is performed at the start-up of the live wallpaper. After that, the live wallpaper should run continuously. However, it seems that on some Samsung foldable devices the live wallpaper will restart whenever the screen is changed; this will also require the heavy loading to be restarted which is unwanted behavior… I don’t get the same behavior on foldable emulators (from Android Studio); but I am able to reproduce the behavior on Samsung Remote Test Lab, so I believe this behavour is implemented by Samsung. Is there a way for me to avoid ‘Surface’/wallpaper destruction? I tried to look into configChanges and other things but it seems that the system forces the wallpaper to be destroyed whenever the display is changed to the other. I believe the only thing left might be to preserve the EGLContext (by detaching and re-attaching, but I am not even sure if that will work; additionally it would be cumbersome to implement such logic…). Is there something I perhaps overlooked that would fix this easily?

Does anyone have helpful tips?



It’s unlikely to get help from this thread, the Samsung themes are almost just design, no programming.

I’d try to call GLSurfaceView.setPreserveEGLContextOnPause(true), this will tell Android to try to keep the opengl context between pause and resume. If it doesn’t work, I’d try first to make sure that the process itself is not killed and started again. Because in that case, there is probably nothing you can do, so it’s better to give up.

I hope it helps,



Thank you for your response. I originally posted this thread under Mobile but it got moved here for some reason…

I already use GLSurfaceView.setPreserveEGLContextOnPause(true), which works on most devices as the live wallpaper will just be paused when not visible. However, on some of the Samsung Fold devices it seems that the wallpaper gets destroyed when switching screens/displays. Therefore, the whole live wallpaper service/process is killed and restarted upon entering the original screen/display again. I thought I could still perhaps preserve the EGLContext by managing it myself (rather than letting GLSurfaceView handle it (which also gets destroyed…)). This seems quite cumbersome still…

I’d try first to see if some static data remains initialized, which would mean in principle that you have a chance of preserving the EGLContext context (not a guarantee but it may be worth pursuing such a solution). Then check if onDestroy was called. In theory, there you should release any resources like EGLContext, otherwise there can be other issues later.