tags:

views:

47

answers:

1

Like the title says, what is the difference between a dialog being dismissed or canceled in Android?

+2  A: 

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.

For example, you have a standard Yes/No dialog on the screen. If the user clicks No, then the dialog is dismissed and the value for No is returned to the caller. If instead of choosing Yes or No, the user clicks Back to escape the dialog rather than make a choice then the dialog is canceled and no value is returned to the caller.

Lee
Thanks for the reply. I'm trying to set what happens if the user pushes the cancel button on a datepicker. First I tried using a dismiss listener, and that worked, but also happened if the user chose a time. Then I tried a cancel listener, and it never went off, even if I pushed cancel. Do you know what I should do?
Aal
If you're using a DatePickerDialog, you should use an OnDateSetListener to get notified when the date changes. If someone clicks the cancel button ... then it won't get called and the dialog will go away on its own. For normal uses of the DatePickerDialog, you don't need to set other listeners.
Lee