Android‎ > ‎

Getting Current Activity Orientation

posted Dec 4, 2012, 3:07 AM by Akash Khaitan   [ updated Mar 9, 2013, 7:39 AM ]
In the manifest file
Inside the activity tag, declare

android:configChanges="orientation"

getResources().getConfiguration().orientation
, inside the activity returns integer which can be used to put suitable condition as shown below

For Landscape Orientation
if(getResources().getConfiguration().orientation==Configuration.ORIENTATION_LANDSCAPE)
{
    //write some conditions here
}


For Portrait
if(getResources().getConfiguration().orientation==Configuration.ORIENTATION_PORTRAIT)
{
    //write some conditions here
}


Comments