I have a FragmentActivity that hosts a DialogFragment.
The DialogFragment perform network requests and handles Facebook authentication, so I need to retain it during
This is a convenience method using the fix from antonyt's answer:
public class RetainableDialogFragment extends DialogFragment {
public RetainableDialogFragment() {
setRetainInstance(true);
}
@Override
public void onDestroyView() {
Dialog dialog = getDialog();
// handles https://code.google.com/p/android/issues/detail?id=17423
if (dialog != null && getRetainInstance()) {
dialog.setDismissMessage(null);
}
super.onDestroyView();
}
}
Just let your DialogFragment extend this class and everything will be fine. This becomes especially handy, if you have multiple DialogFragments in your project which all need this fix.