0

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?

2
  • Why do you need to know the difference? In general I would expect any UI to work (look) the same in either landscape position.
    – Squonk
    Oct 7, 2011 at 22:07
  • I need to recalcute the touchevent cordinates. So i need the right Rotation Oct 7, 2011 at 22:19

1 Answer 1

1

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.