How to use onConfigurationChanged() and newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE in android 2.3.3

Just write the below code into onConfigurationChanged method and test

if(newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE){

    Log.e("On Config Change","LANDSCAPE");
}else{

    Log.e("On Config Change","PORTRAIT");
}

and write the android:configChanges="keyboardHidden|orientation" into your manifiest file like this

<activity android:name="TestActivity"
           android:configChanges="keyboardHidden|orientation">

it’s working at my side, i hope it helps you.

If you’re on tablet also add |screenSize to android:configChanges

Leave a Comment