0 votes
1 view
in Java by (3.5k points)

How can I check if the Android phone is in Landscape or Portrait?

1 Answer

0 votes
by (46.1k points)

The present configuration, as used to know which resources to retrieve, is present in the Resources' Configuration object:


You can view for orientation by searching at its value:

int orientation = getResources().getConfiguration().orientation;

if (orientation == Configuration.ORIENTATION_LANDSCAPE) {

    // In landscape

} else {

    // In portrait


More data can be observed in the Android Developer.

Related questions

0 votes
1 answer
asked Oct 15, 2019 in Java by Shubham (3.9k points)
0 votes
1 answer
0 votes
1 answer
asked Sep 9, 2019 in Java by Anvi (10.2k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !