Code example for FragmentManager

Methods: beginTransactionfindFragmentByTag

            FragmentManager fm = getFragmentManager();
            // Check to see if we have retained the worker fragment. 
            mWorkFragment = (RetainedFragment)fm.findFragmentByTag("work");
            // If not retained (or first time running), we need to create it. 
            if (mWorkFragment == null) {
                mWorkFragment = new RetainedFragment();
                // Tell it who it is working with. 
                mWorkFragment.setTargetFragment(this, 0);
                fm.beginTransaction().add(mWorkFragment, "work").commit();
     * This is the Fragment implementation that will be retained across