I had a similar issue with ordering DialogFragments. In my case, I had a dialog to set a time period, and so he had to run another dialog to select dates. Therefore, after displaying the second dialog and changing the screen orientation, the order of the two dialogs is reversed, similar to your problem.
So my solution was to create a FragmentActivity that looks like a dialog. Then I replaced it with the first dialog. That way, I could better manage the state of the instance state, etc. With a life cycle of activity. This activity was then called, as usual, the second dialogue, without transferring anything else.
My other action, which was actually called the previous (first) dialogue, then simply caused a new action for the result, and it was!
Here's more details on how to make an activity look like a dialogue:
class MyDialogActivity extends FragmentActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.my_dialog_layout); LayoutParams params = getWindow().getAttributes(); params.height = LayoutParams.WRAP_CONTENT; params.width = LayoutParams.WRAP_CONTENT; getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); setTitle("my dialogs title"); setTheme(DialogFragment.STYLE_NORMAL);
Hope this helps you, or at least gives you an idea of a workaround for this ugly Android bug! Best wishes.
source share