Code example for FragmentActivity

Methods: onSaveInstanceState

0
        } 
    } 
 
    @Override 
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putInt("level", mStackLevel);
    } 
 
 
    void addFragmentToStack() { 
        mStackLevel++;
 
        // Instantiate a new fragment. 
        Fragment newFragment = CountingFragment.newInstance(mStackLevel);
 
        // Add the fragment to the activity, pushing this transaction 
        // on to the back stack. 
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.replace(R.id.simple_fragment, newFragment);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);