Reputation: 3
I´m trying to get the right landscape Rotation. What I have done until now:
AndroidManifest.xml
android:configChanges="keyboardHidden|orientation"
Code to handle
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Log.i("RemoDroid", "Landscape");
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
Log.i("RemoDroid", "portrait"); // 0
}
}
So portrait is clear = 0° But landscape can be 90° or 270°. How to find this out. Im looking for a smart solution if possible. I do not want to use Orientation-/Rotationmatrix and get oriantation of axis.
Do any one have a solution?
Upvotes: 0
Views: 2612
Reputation: 20309
You can use Display.getOrientation()
which returns one of the following:
Surface.ROTATION_0
Surface.ROTATION_90
Surface.ROTATION_180
Surface.ROTATION_270
For me information see the Android Display docs.
Upvotes: 1