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

后端 未结 6 1775
既然无缘
既然无缘 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 05:50

    Write below code in your activity file.

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
    
        if(newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE){
         Log.e("On Config Change","LANDSCAPE");
        }
        else{
         Log.e("On Config Change","PORTRAIT");
        }
    
    }
    

    Also write below code in your manifest file as follows:

    
    

提交回复
热议问题