在取消Dialog时,dismiss方法和cancel方法都能满足要求。
主要区别在于调用cancel方法时不仅仅会调用dismiss方法,还会调用你实现的DialogInterface.OnCancelListener方法。
DialogInterface.OnCancelListener是一个静态的接口:Interface used to allow the creator of a dialog to run some code when the dialog is canceled.
reference:
https://developer.android.com/reference/android/content/DialogInterface.OnCancelListener
https://developer.android.com/reference/android/app/Dialog#cancel