1.返回时Activity生命周期走onPause()--onStop()--onDestory(),在 onPause()方法中设置
@Override
protected void onPause() {
super.onPause();
LogUtil.e("Tag","======onPause");
if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//竖屏
}
}
@Override
protected void onResume() {
super.onResume();
LogUtil.e("Tag","======onResume");
if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);//横屏
}