How can I check if the Android phone is in Landscape or Portrait?
It's also worth noting that nowadays, there's less good reason to check for explicit orientation with getResources().getConfiguration().orientation
if you're doing so for layout reasons, as Multi-Window Support introduced in Android 7 / API 24+ could mess with your layouts quite a bit in either orientation. Better to consider using
, and alternative layouts dependent on available width or height, along with other tricks for determining which layout is being used, e.g. the presence or not of certain Fragments being attached to your Activity.