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

后端 未结 6 1782
既然无缘
既然无缘 2020-11-27 05:28

I am using onConfigurationChanged(). In that, when I am changing from LandScape to Portrait, it is calling if (newConfig.orientation == Configuration.ORIE

6条回答
  •  清歌不尽
    2020-11-27 06:04

    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

    
    

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

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

提交回复
热议问题