Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between ` DialogInterface.dismiss()` and `DialogInterface.cancel()`? [duplicate]

Tags:

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.

like image 661
Chaitanya K Avatar asked Aug 27 '12 09:08

Chaitanya K


People also ask

What is the difference between dismiss and cancel?

Typically, a dialog is dismissed when its job is finished and it is being removed from the screen. A dialog is canceled when the user wants to escape the dialog and presses the Back button.

What is DialogInterface?

DialogInterface.OnMultiChoiceClickListener. Interface used to allow the creator of a dialog to run some code when an item in a multi-choice dialog is clicked.

What is dialogue box in android?

A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed. Dialog Design.


2 Answers

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

like image 105
AAnkit Avatar answered Oct 21 '22 07:10

AAnkit


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

like image 21
dgjorg Avatar answered Oct 21 '22 06:10

dgjorg