Hi! There is something in the Android API example FragmentTabs.java (http://developer.android.com/resources/samples/ApiDemos/src/com/ example/android/apis/app/FragmentTabs.html) that I do not understand. I will try to explain my problem step-by-step:
First, in the onCreate method of the main activity new actionbar tabs are added, e.g.: bar.addTab(bar.newTab() .setText("Simple") .setTabListener(new TabListener<FragmentStack.CountingFragment>( this, "simple", FragmentStack.CountingFragment.class))); The TabListener class used above implements ActionBar.TabListener and is responsible for creating (add) and managing (attach, detach) the fragments that are displayed for each tab. Additionally the TabListener constructor also contains the following code that checks if a fragment already exists: // 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(); } It turns out that the if statement above is true when the Android device changes its orientation, so the extra detach for the fragment has to be executed in this case. What I do not understand is why a fragment can still exist at that point. On orientation change the main activity containing all fragments is destroyed and recreated. I also do not see anything saving the fragment in a bundle or something. Therefore I would expect that all fragments are also destroyed when the activity is destroyed and recreated but this seems to be a wrong assumption. BTW, executing getBackStackEntryCount() seems to always return zero during program execution. Thanks in advance for any help. Regards, Anguel -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en