The listener here is to feedback the click on the negative button, which is cancel button. So the __Close__ of the dialog is not handled if it's done by other means than clicking the negative button. e.g. click the empty space out of the dialog window, or just click the physical back button.

Actually, I always recommend following if using AlertDialog Builder.
```
builder.setPositiveButton(R.string.ok, null)
       .setNegativeButton(R.string.cancel, null)
       .setOnDismissListener(new DialogInterface.OnDismissListener() {
           public void onDismiss() {
               // Do what originally put in on click listener of positive button here.
           }
       }).setOnCancelListener(new DialogInterface.OnCancelListener() {
           public void onCancel() {
               // Do what originally put in on click listener of negative button here.
           }
       });       
```
It's because, if using AlertDialog, click on Negative button will automatically cancel the dialog with no need to call `dialog.cancel()`, similarly with Positive button and `dialog.dismiss()`.