Android Device Orientation Change Call Back

Hey there,
I’m porting a popuplar OFX iOS game to Android and am confused on how to detect and apply orientation changes. Seems like a noob question but I can’t find the solution!

For a fixed landscape orientation; what to do is;

inside the manifest:

android:label="@string/app_name" android:screenOrientation="landscape" android:configChanges="orientation">

and in the beginning of setup() of the ofApp.cpp:

ofSetOrientation(OF_ORIENTATION_90_LEFT);

For an autorotating orientation; I think ofGetOrientation() may do the extra trick to get the current orientation of the device. (+some tuning in the manifest may be needed)

Well, after a while I am currently working on app orientation. I want to share something with people who use orientation feature.

If you added, please comment out the line

ofSetOrientation(OF_ORIENTATION_90_LEFT);

and in the AndroidManifest.xml, change

android:screenOrientation="landscape"

to

android:screenOrientation="sensorLandscape"

Then run the app.

Try rotating your device in your hand. It works for me and it looks more beautiful than the fixed landscape. (Other sensor orientations should also work for different app layouts than our game.)

The only problem I found is; if you use ofCamera in the scene, it conflicts with the sensor orientation change. I will sent a pull request soon to fix this conflict in the OF’s master repo.