@@ -566,7 +566,14 @@ public Builder setCancelable(boolean cancelable) {
566566
567567 /**
568568 * Sets the callback that will be called if the dialog is canceled.
569+ *
570+ * <p>Even in a cancelable dialog, the dialog may be dismissed for reasons other than
571+ * being canceled or one of the supplied choices being selected.
572+ * If you are interested in listening for all cases where the dialog is dismissed
573+ * and not just when it is canceled, see
574+ * {@link #setOnDismissListener(android.content.DialogInterface.OnDismissListener) setOnDismissListener}.</p>
569575 * @see #setCancelable(boolean)
576+ * @see #setOnDismissListener(android.content.DialogInterface.OnDismissListener)
570577 *
571578 * @return This Builder object to allow for chaining of calls to set methods
572579 */
@@ -575,6 +582,16 @@ public Builder setOnCancelListener(OnCancelListener onCancelListener) {
575582 return this ;
576583 }
577584
585+ /**
586+ * Sets the callback that will be called when the dialog is dismissed for any reason.
587+ *
588+ * @return This Builder object to allow for chaining of calls to set methods
589+ */
590+ public Builder setOnDismissListener (OnDismissListener onDismissListener ) {
591+ P .mOnDismissListener = onDismissListener ;
592+ return this ;
593+ }
594+
578595 /**
579596 * Sets the callback that will be called if a key is dispatched to the dialog.
580597 *
@@ -917,6 +934,7 @@ public AlertDialog create() {
917934 dialog .setCanceledOnTouchOutside (true );
918935 }
919936 dialog .setOnCancelListener (P .mOnCancelListener );
937+ dialog .setOnDismissListener (P .mOnDismissListener );
920938 if (P .mOnKeyListener != null ) {
921939 dialog .setOnKeyListener (P .mOnKeyListener );
922940 }
0 commit comments