1. 程式人生 > >關於Android的Activity的onCreate多次呼叫的問題

關於Android的Activity的onCreate多次呼叫的問題

@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);
    }