2

How to distinguish between Landscape (Right/Left) vs Portrait (Up/Down) on android? I tried:

getResources().getConfiguration().orientation

and it always returns Configuration.ORIENTATION_PORTRAIT.

also, I checked:

How to detect landscape left (normal) vs landscape right (reverse) with support for naturally landscape devices?

Check orientation on Android phone

I tried the onConfigurationChanged as well. I cannot get Right vs Left on landscape mode (up vs down on portrait).

Is there a clean way of finding this on Android 5.0+?

Note: My activity could be launched with any orientation. Capturing orientation changes using a listener may not be viable since I want the real orientation of the phone (even before I get a callback on orientation changes).

Also, by default:

android:screenOrientation="portrait"

Note: My activity responds to auto-rotate changes.

Community
  • 1
  • 1
ssk
  • 9,045
  • 26
  • 96
  • 169

0 Answers0