Friday, June 10, 2011

Handling Orientation Change in Android

If you want perform some operation in the orientation the following snippet useful. If you change the orientation then one default method will call i.e onConfigurationChanged()

 public void onConfigurationChanged(Configuration newConfig)
         if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
                  // indicates orientation changed to landscape
         else if(newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
                  // indicates orientation changed to portrait

Note :
We will change the declaration of the Activity in manifast.xml to the following :
<activity android:name=".YourActivity" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden" />

If you want know more information about this plz follow the link :   

No comments:

Post a Comment