[Android] SDL app crashes if the screen is locked

If you lock the screen during run time the
app crashes if you try to run the app after unlcoking the screen.

It seems sdl call onDestroy instead onPause if you lock the screen.

I think I had the same problem and fixed it by checking whether the app
is really quitting.

The trick was to add the following lines to the onDestroy() function of
SDLActivity():

if (!isFinishing()) {
Log.v(“SDL”, “Not quitting native app as isFinishing() is false”);
return;
}

See here:
https://bitbucket.org/MartinFelis/love-android-sdl2/src/f09239788a9dc78d4e182a2f92224d0b17ec0883/src/org/libsdl/app/SDLActivity.java?at=master#cl-126

It also fixed a crash when the orientation was changed.

Cheers,
MartinOn 21.03.2014 17:05, PauliusM wrote:

It seems sdl call onDestroy instead onPause if you lock the screen.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

This workaround is effective only because you are not using the latest
SDLActivity.java file from SDL, which now explicitly clears the static
variables when onDestroy is called. You are basically not quiting when
Android tells you to, and relying on the fact that class static variables
are retaining their value to maintain the status of the app until your
Activity is created again.

If you are getting a onDestroy message with orientation or lock screen it’s
probably something that can be solved with a configuration setting, it’s
worth looking into.

Other than that, please file a bug report with the crash log so I can look
into it. Thanks!

2014-03-23 14:18 GMT-03:00 Martin Felis :> I think I had the same problem and fixed it by checking whether the app

is really quitting.

The trick was to add the following lines to the onDestroy() function of
SDLActivity():

if (!isFinishing()) {
Log.v(“SDL”, “Not quitting native app as isFinishing() is false”);
return;
}

See here:

https://bitbucket.org/MartinFelis/love-android-sdl2/src/f09239788a9dc78d4e182a2f92224d0b17ec0883/src/org/libsdl/app/SDLActivity.java?at=master#cl-126

It also fixed a crash when the orientation was changed.

Cheers,
Martin

On 21.03.2014 17:05, PauliusM wrote:

It seems sdl call onDestroy instead onPause if you lock the screen.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Gabriel.