Android DialogFragment disappears after orientation change

Okay, so the issue seems to be with the DialogFragment compatibility library.

The issue was described in this post.

“An obsolete DISMISS message for the fragment is retained in the message queue. It’s been queued by DialogFragment.onDestroyView() when dismissing the old dialog and gets reactivated after creating the new dialog.

A quick (and possibly dirty) workaround is to override onDestroyView() and clear the dismiss listener before calling super.onDestroyView()

Adding the following code to my DialogFragment solved the issue:

 @Override
 public void onDestroyView() {
     if (getDialog() != null && getRetainInstance()) {
         getDialog().setDismissMessage(null);
     }
     super.onDestroyView();
 }

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)