關於Android的Activity的onCreate多次呼叫的問題
阿新 • • 發佈:2019-02-20
@Override
public void onConfigurationChanged(Configuration newConfig) {
// TODO Auto-generated method stub
if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
System.out.println("ORIENTATION_LANDSCAPE="
+ Configuration.ORIENTATION_LANDSCAPE);// 當前為橫屏
} else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
System.out.println("ORIENTATION_PORTRAIT="
+ Configuration.ORIENTATION_PORTRAIT);// 當前為豎屏
}
super.onConfigurationChanged(newConfig);
}
public void onConfigurationChanged(Configuration newConfig) {
// TODO Auto-generated method stub
if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
System.out.println("ORIENTATION_LANDSCAPE="
+ Configuration.ORIENTATION_LANDSCAPE);// 當前為橫屏
} else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
System.out.println("ORIENTATION_PORTRAIT="
+ Configuration.ORIENTATION_PORTRAIT);// 當前為豎屏
}
super.onConfigurationChanged(newConfig);
}