我正在使用以下代码在用户旋转设备时更改我的活动方向。这第一次工作正常,但不再调用。请纠正我。
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Log.d("ACTIVITY","CHANGING ORIENTATION"); //No i18n
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
Log.d(TAG, "ORIENTATION CHANGED TO PORTRAIT"); // No I18N
setRequestedOrientation(Configuration.ORIENTATION_PORTRAIT);
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Log.d(TAG, "ORIENTATION CHANGED TO LANDSCAPE"); // No I18N
setRequestedOrientation(Configuration.ORIENTATION_LANDSCAPE);
}
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
Log.d("ACTIVITY","ON RESTORE INSTANCESTATE"); //No i18n
super.onRestoreInstanceState(savedInstanceState);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
Log.d("ACTIVITY","ON SAVE INSTANCESTATE"); //No i18n
super.onSaveInstanceState(outState);
}