exiting android game loop |
Owen Alanzo Hogarth
Guest
|
I was reading this article:Â https://forums.libsdl.org/viewtopic.php?t=9853&sid=015c4716f861c7491ec21972d2edefea
it seems to state avoid using exit(0); from my c source on case SDLK_AC_BACK: but using sdl_quit(); causes the application to hang and then if I click the app icon it'll just open and immediately close but the last frame is still rendered. What's the way to properly exit an android app? It probably applies to all mobile devices as well. |
|||||||||||
|
exiting android game loop |
Eric Wing
Guest
|
On 8/20/15, Owen Alanzo Hogarth wrote:
You should end your gameloop, and before your int main() returns, call SDL_Quit(). Also shutdown and cleanup any other things that need shutdown handling. On Android, when an app quits, the memory is not necessarily deinitialized. In particular, static variables are problematic because they will not be reinitialized on the next run unless Android has purged this memory somehow (force kill, reboot, reaping). If your app is hanging on the next run, this is probably due to some static variable that has a value from the previous run and is not getting reinitialized. So you need to make sure you clean these up. Calling exit() basically kills the app which avoids this problem, but is a really bad thing to do on Android for other reasons. -Eric _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
MrTAToad
|
Its always a good idea to shutdown sdl_mixer, sdl_image etc before calling SDL_Quit too...
|
|||||||||||
|
exiting android game loop |
Owen Alanzo Hogarth
Guest
|
thanks for the tips, it seems if I call SDL_Quit(); android hangs and if I try to reopen the app it just auto exits again until I force close the app.
calling exit(0); for android seems to work the best. So far it's worked the best by catching the android exit call, quitting image, mixer, saving whatever data I need to save then calling exit(0); thanks for all the tips. On Fri, Aug 21, 2015 at 7:28 PM, MrTAToad wrote:
|
|||||||||||||
|
exiting android game loop |
Gachapen
|
I had similar issues myself with 2.0.3. I ended up disabling the back button then (horrible I know). Now I use the latest hg version of SDL and SDL_Quit() quits the application properly. It seems they fixed it after 2.0.3. I suggest you try the hg version.
- Magnus On Fri, Aug 21, 2015, 14:28Â Owen Alanzo Hogarth wrote:
|
|||||||||||||||
|