How can I check if the Android phone is in Landscape or Portrait?
Another way of solving this problem is by not relying on the correct return value from the display but relying on the Android resources resolving.
Create the file layouts.xml
in the folders res/values-land
and res/values-port
with the following content:
res/values-land/layouts.xml:
true
res/values-port/layouts.xml:
false
In your source code you can now access the current orientation as follows:
context.getResources().getBoolean(R.bool.is_landscape)