I had the same problem with orientation changes, but this only happened with older versions of Android (4.0.4), newer versions like 4.4.2 were fine. I want to share with you how I fixed it.
As suggested by Kenny and Joanne, I used
FragmentManager.enableDebugLogging(true);
and found out that too much removal has been done. I had to remove ft.remove(df) from my code, and now it is good in both versions mentioned above. This is my code:
if (savedInstanceState != null) { final FragmentTransaction ft = getFragmentManager().beginTransaction(); final DialogFragment df = (DialogFragment) getFragmentManager().findFragmentByTag("tag"); if (df != null) { df.dismiss(); // ft.remove(df); frag = new MyDialogFragment(); frag.show(getFragmentManager(), "tag"); } ft.addToBackStack(null); ft.commit(); }
For completeness, this is what I did in onSaveInstanceState(final Bundle outstate) :
if (frag != null) { getFragmentManager().putFragment(outState, "tag", frag); }
User42
source share