Activity restart on rotation Android

前端 未结 30 3830
花落未央
花落未央 2020-11-21 04:32

In my Android application, when I rotate the device (slide out the keyboard) then my Activity is restarted (onCreate is called). Now, this is proba

30条回答
  •  旧巷少年郎
    2020-11-21 05:12

    Add this line to your manifest :-

    android:configChanges="orientation|keyboard|keyboardHidden|screenSize|screenLayout|uiMode"
    

    and this snippet to the activity :-

    @Override
        public void onConfigurationChanged(Configuration newConfig) {
            super.onConfigurationChanged(newConfig);
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
    

提交回复
热议问题