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:

getResources().getConfiguration().orientation;

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.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...