myDialog.dismiss() 和 myDialog.getDialog().dismiss() 有什么区别?

What is the difference between myDialog.dismiss() and myDialog.getDialog().dismiss()?

正如我在标题中提到的

这个..

public void dismissDialog(MyDialog dialog){
    dialog.dismiss();
}

还有这个..

public void dismissDialog(MyDialog dialog){
    dialog.getDialog().dismiss();
}

我应该使用哪一个?或者它们之间甚至有区别吗?

编辑 1:MyDialog 是一个 DialogFragment

来自Documentation

public void dismiss()

Dismiss the fragment and its dialog. If the fragment was added to the back stack, all back stack state up to and including this entry will be popped. Otherwise, a new transaction will be committed to remove the fragment.

所以dismiss()方法不仅关闭了对话框,还对流程中涉及的片段事务进行了管理。但是 dialog.getDialog().dismiss() 只会关闭对话框。

关闭 DialogFragment 的正确方法是使用 dismiss()。