While working with dialogs in android one can cancel it or dismiss it, But when to use dismiss and when to use cancel? what is the difference between them? Thanks in advance.
问题:
回答1:
public void cancel () Since: API Level 1
Cancel the dialog. This is essentially the same as calling dismiss(), but it will also call your DialogInterface.OnCancelListener (if registered).
This is what docs says, Both are same, just cancel() will call the listener registered on DialogInterface.
Reference link
see this ANSWER too for reference
回答2:
cancel() - Cancel the dialog. This is essentially the same as calling dismiss(), but it will also call your DialogInterface.OnCancelListener (if registered).
dismiss() - Dismiss this dialog, removing it from the screen. This method can be invoked safely from any thread. Note that you should not override this method to do cleanup when the dialog is dismissed, instead implement that in onStop().
You should check here for more info how to use this two methods