IllegalStateException( “You can not set Dialog’s OnCancelListener or OnDismissListener”)

From Android documentation:

public Dialog onCreateDialog (Bundle savedInstanceState)

Override to build your own custom Dialog container. This is
typically used to show an AlertDialog instead of a generic Dialog;
when doing so, onCreateView(LayoutInflater, ViewGroup, Bundle) does
not need to be implemented since the AlertDialog takes care of its own
content.

This method will be called after onCreate(Bundle) and before
onCreateView(LayoutInflater, ViewGroup, Bundle). The default
implementation simply instantiates and returns a Dialog class.

Note: DialogFragment own the Dialog.setOnCancelListener and Dialog.setOnDismissListener callbacks. You must not set them yourself.

To find out about these events, override onCancel(DialogInterface) and
onDismiss(DialogInterface).

So basically, you must override the onDismiss or OnCancel instead of ‘.setOnCancelListener(onCancelListener)’.

Leave a Comment

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