1

I want to execute a code before closing my dialog fragment when touching it outside. Is there a simple way to achieve this?

I tried to override "onDismiss" method, but the DialogFragment is dismissed before writing the log.

@Override
public void onDismiss(DialogInterface dialog) {
    Log.d(Constants.TAG,"Dialog will be dismissed");
    super.onDismiss(dialog);
}

1 Answers1

0

Override setOnDismissListener(...) method of class Dialog

Karan
  • 2,120
  • 15
  • 27
  • I already tried that, but I receive this message on logcat: java.lang.IllegalStateException: "You can not set Dialog's OnCancelListener or OnDismissListener" – Stélvio Carvalho Mar 22 '15 at 16:14
  • Override onDismiss or onCancel, since setoOnDismissListener should not be overriden for Custom dialogs – Karan Mar 22 '15 at 16:20
  • Yes, it is a custom one. Didn't knew it would make a difference. Anyway my problem keeps unsolved because the dialog always closes before executing the code I want. – Stélvio Carvalho Mar 22 '15 at 16:51
  • Can you share the snippet? – Karan Mar 22 '15 at 16:52