I'm using two overlapped DialogFragment
(I know, maybe it is not a good design pattern), and I have problem on orientation changes.
When the orientation changes, the most external DialogFragment
(the smallest) go behind the most internal.
The simplest solution for my application can be to dismiss the most external DialogFragment, but I'm not able to do it, since setRetainInstance(false)
seems not working with DialogFragment
.
The fragment are added dinamically, calling:
DialogFragment fragment = CreateEventFragment.newInstance(0);
fragment.show(getFragmentManager(), CreateEventFragment.FRAGMENT_TAG);
I solved the problem, overriding the onSaveInstanceState
, in this way:
@Override
public void onSaveInstanceState(Bundle outState) {
if(outState==null)
super.onSaveInstanceState(outState);
}
Now, after orentation changes, the outmost DialogFragment
is mainteined external, so they are recreated in the right order.