What is the difference between a dialog being dismissed or canceled in Android?

前端 未结 4 902
醉酒成梦
醉酒成梦 2020-12-02 05:27

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

4条回答
  •  一向
    一向 (楼主)
    2020-12-02 06:27

    The difference is all about returning the value to the caller function.

    dialog.cancel() will normally be called when the user hits the back button rather than selecting the choices that alert dialog offers like OK/Dismiss and return null/no value to the caller. While

    dialog.dismiss() is normally called when the user selects from the choices that alert dialog offers like hitting the Dismiss button on the dialog will dismiss the dialog and will return the non-null corresponding value to the caller. That's it.

提交回复
热议问题