Showing posts with label Current screen orientation. Show all posts
Showing posts with label Current screen orientation. Show all posts

Friday, June 10, 2011

getting current screen orientation in android

The following snippet gives the current screen orientation.

public int getScreenOrientation()
{
        return getResources().getConfiguration().orientation;
}

The above method return integer. We will compare as follows.

 if(getScreenOrientation() == Configuration.ORIENTATION_PORTRAIT)
 {
            //App is in Portrait mode
 }
 else
{
           //App is in LandScape mode
}