1
我正在使用以下代碼在用戶旋轉設備時更改我的活動方向。這工作正常,但沒有再次調用。請糾正我。onConfigurationChanged第二次未調用
@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);
}
謝謝。怎麼做? – vignesh
終於!我正在尋找一個類似的解決方案几個小時 –