Changing orientation

i’ve been battling with the problem of changing orientation under Android.

i’ve been foolishly following wild geese trying to find why my app quits when i change orientation until i discover that apps QUIT when changing orientation! more specifically, they are restarted in the new position.

Turned out this was causing my app to crash due to a global static singleton i was using. statics in the jni do not get reset through this restart.

i fixed this and it works but, as you might expect, it is slow to come up due to starting over, reading config files and all that. so i’ve been trying to change the build so that it does not do this restart malarkey.

here are my changes that worked here. i’m hoping Jules might put something like this into the official Juce build, because i think the default restart behaviour is poor.

i added the following to the tag in AndroidManifest.xml

then i changed the default Activity subclass generated by Juce as follows,

import android.content.res.Configuration;

public void onConfigurationChanged(Configuration cfg)
setContentView (viewHolder);

this worked for me on actual hw. it’s possible that there’s more to it than this. there always is.

– hugh.

It quits and restarts!? Wow, that’s a pretty hardcore way of rotating.

Nice one, thanks, I’ll get those changes in right away!

yeah, crazy isnt it!

although i understand it doesnt totally quit from a Java point of view. `quitApp’ is called on the jni though. my changes seem to be working, although i havent it with a sliding keyboard.

– hugh.

The configuration lifecycle stuff is documented here:

Android will stop and restart your activity for orientation changes if you don’t handle configuration changes, but there are some API version specific things with the configuration mechansim too.