Android: howto pause and resume?

Hi,

In normal Android applications you can declare variables in your Activity static. Then, if you touch the home or the back sign, and then come back later to the same app, the static variables will have kept their value, and the onCreate method can recreate your app like you left it, using these static variables. This is very convenient, so I tried to achieve the same behavior using SDL and the Android NDK. Alas, I could not find a way.

Who knows how to do this? Which events must be polled? How must the relevant variables be stored? Any help will be much appreciated.

wboe

2012/11/6 wboe <w.boeke at upcmail.nl>

**
Hi,

In normal Android applications you can declare variables in your Activity
static. Then, if you touch the home or the back sign, and then come back
later to the same app, the static variables will have kept their value, and
the onCreate method can recreate your app like you left it, using these
static variables. This is very convenient, so I tried to achieve the same
behavior using SDL and the Android NDK. Alas, I could not find a way.

Who knows how to do this? Which events must be polled? How must the
relevant variables be stored? Any help will be much appreciated.

wboe

SDL handles pausing/resuming of your app automatically under Android. See
the README.android (
http://hg.libsdl.org/SDL/file/35de500cc918/README.android) file, under
the “Pause
/ Resume behaviour” entry, to see if that clears up your doubts.–
Gabriel.

Hi gabomdq,

Thanks for your reply, but of course I knew this document already. The problem is however that only the GL context is restored, but an app contains more then that… It is not clear how other variables should be recovered.

wboe

2012/11/6 wboe <w.boeke at upcmail.nl>

**
Hi gabomdq,

Thanks for your reply, but of course I knew this document already. The
problem is however that only the GL context is restored, but an app
contains more then that… It is not clear how other variables should be
recovered.

wboe

I guess I don’t understand your question then, what exactly are you losing
when switching apps that you would like to recover? The SDLActivity is a
singleton and it lives for the entirety of your app’s life, anything you
store there will be always available.–
Gabriel.

Hi Gabriel,

You are right! I put my unbelief on hold, recompiled with SDL_ANDROID_BLOCK_ON_PAUSE defined, and it works! Not only the GL context is restored, but the complete app. Thanks!

Wouter Boeke

This is now the default behavior.

Thanks!On Tue, Nov 6, 2012 at 8:59 AM, wboe <w.boeke at upcmail.nl> wrote:

**
Hi Gabriel,

You are right! I put my unbelief on hold, recompiled with
SDL_ANDROID_BLOCK_ON_PAUSE defined, and it works! Not only the GL context
is restored, but the complete app. Thanks!

Wouter Boeke


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