The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
In Android, rotation of the phone restarts the app
yaronct


Joined: 10 Mar 2015
Posts: 9
Hi,

When I rotate the phone, i.e. from portrait orientation to landscape orientation, the app restarts ("main" is called again). Obviously, what I would expect is simply to receive a window resize event, rather than restart. Is this a bug?

I'm using SDL 2.0.3 with Android 5.1 on Nexus 5 (real device).
yaronct


Joined: 10 Mar 2015
Posts: 9
A bit more research shows that when the orientation of the device changes, it sends an "SDL_QUIT" event. If, when receiving this event, I quit (by simply aborting the main loop in "main"), the application is restarted, and "main" is called again. If I ignore the "SDL_QUIT" event, the OS gets stuck. I still have no idea of to solve this.
AntTheAlchemist


Joined: 13 Feb 2015
Posts: 60
Location: UK
Did you solve this yet?

My Android app doesn't close when rotation changes. I get window resize events, but no SDL_QUIT event. SDL_QUIT will be produced if you close the window and don't create a new one. How are you handling window events?
In Android, rotation of the phone restarts the app
Eric Wing
Guest

On 4/6/15, AntTheAlchemist wrote:
Quote:
Did you solve this yet?

My Android app doesn't close when rotation changes. I get window resize
events, but no SDL_QUIT event. SDL_QUIT will be produced if you close the
window and don't create a new one. How are you handling window events?



This sounds like you didn't put in the correct keys in your
AndroidManifest.xml. By default, Android will restart your application
every time there is a rotation, keyboard dismissal, screen size
change, and maybe some other criteria. (I think it is shameful that
they thought this is reasonable default behavior and still haven't
fixed it.)

android:configChanges="orientation|keyboardHidden|screenSize"


-Eric
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
yaronct


Joined: 10 Mar 2015
Posts: 9
Eric,

Thanx, this has solved my problem. Perhaps it would be best to change the "AndroidManifest.xml" that comes with SDL, as it doesn't contain the "screenSize". Or at least point that out in the SDL documentation for Android.
In Android, rotation of the phone restarts the app
Bill Kendrick
Guest

On Mon, Apr 06, 2015 at 07:09:09PM -0700, Eric Wing wrote:
Quote:
On 4/6/15, AntTheAlchemist wrote:
Quote:
Did you solve this yet?

My Android app doesn't close when rotation changes. I get window resize
events, but no SDL_QUIT event. SDL_QUIT will be produced if you close the
window and don't create a new one. How are you handling window events?



This sounds like you didn't put in the correct keys in your
AndroidManifest.xml. By default, Android will restart your application
every time there is a rotation, keyboard dismissal, screen size
change, and maybe some other criteria. (I think it is shameful that
they thought this is reasonable default behavior and still haven't
fixed it.)

I remember a short intro demo about Android given at Google Summer
of Code Mentor Summit, years ago, and everyone gasped when they
told us that's how it worked. Kinda surprised it's still the case.
I guess apps manage by having a UI separate from the rest of the
app, or really fast state save/reload...? (Not an Android dev'er,
if that's not obvious Smile )

Still, I'm sure it's better than BREW. (Reasonable API, terrible
implementations. Sad )

--
-bill!
Sent from my computer
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org