how to stop activity recreation on screen orientation?

后端 未结 7 613
情话喂你
情话喂你 2020-12-10 06:25

how i can stop the restarting or recalling of on create() on screen orientation ,i want to stop the recreation of activity on screen orientation. thanks in advance please te

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-10 06:54

    Two ways for this:

    Either you can set android:configChanges="keyboardHidden|orientation" in Manifest file to avoid recreation of activity.

    Or Make the changes you want to apply on changing the orientation inside the overrided method

    @Override

    public void onConfigurationChanged(Configuration newConfig) {
    
                // Perform the actions
    
        super.onConfigurationChanged(newConfig);
    
    }
    

提交回复
热议问题