Dynamic Screen Orientation?

Hi folks, I see by default when the Android MainActivty is generated it sets screen orientation to landscape.

I tried changing it to use: SCREEN_ORIENTATION_SENSOR

and it looks like it does attempt to switch the orientation…but, that appears to cause: OOM…

Is there anything more we need to explicitly handle when changing the orientation to make this work?


W/dalvikvm(11580): threadid=11: thread exiting with uncaught exception (group=0x40a321f8)

E/AndroidHarness(11580): Exception thrown in Thread[GLThread 1228,5,main]

E/AndroidHarness(11580): java.lang.OutOfMemoryError

E/AndroidHarness(11580): at android.graphics.Bitmap.nativeCreate(Native Method)

E/AndroidHarness(11580): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)

E/AndroidHarness(11580): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)

E/AndroidHarness(11580): at com.jme3.asset.AndroidImageInfo.loadBitmap(AndroidImageInfo.java:92)

E/AndroidHarness(11580): at com.jme3.asset.AndroidImageInfo.getBitmap(AndroidImageInfo.java:32)

E/AndroidHarness(11580): at com.jme3.texture.plugins.AndroidImageLoader.load(AndroidImageLoader.java:14)

E/AndroidHarness(11580): at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:282)

E/AndroidHarness(11580): at com.jme3.asset.AndroidAssetManager.loadTexture(AndroidAssetManager.java:113)

E/AndroidHarness(11580): at com.jme3.texture.Texture.read(Texture.java:593)

E/AndroidHarness(11580): at com.jme3.texture.Texture2D.read(Texture2D.java:215)

I put my app in Sensor mode and do not get your error. However, unless you put the configchanges directive in your manifest and onConfigurationChanged() in your MainActivity, your app will be restarted during the configuration change. See this link as well.

I also started putting android:launchMode=“singleTask” in my manifest so the system always returns to the same instance of the app (if there is a paused one) is resumed when you hit the home screen and then go back to the app.

The code locks to the current orientation, not some arbitrary orientation. The code works fine for everything except Honeycomb portrait. I could hardcode that case in there, but it’s not a permanent solution, because device manufacturers can specify any rotation/orientation combination they desire.