In the Android API example FragmentTabs.java I see the following constructor code inside the TabListener class:
// Check to see if we already have a fragment for this tab, probably
// from a previously saved state. If so, deactivate it, because our
// initial state is that a tab isn't shown.
mFragment = mActivity.getFragmentManager().findFragmentByTag(mTag);
if (mFragment != null && !mFragment.isDetached()) {
FragmentTransaction ft = mActivity.getFragmentManager().beginTransaction();
ft.detach(mFragment);
ft.commit();
}
Can someone please give me a hint under which circumstances the if clause can return true? I cannot think of such a situation. Thanks.
When you turn your phone from Portrait to Landscape or back.
The current active tab will not be detached.
I just tested it by putting a breakpoint in that clause.