DialogFragment.dismiss crashing with NullPointerException

后端 未结 6 2004
慢半拍i
慢半拍i 2021-02-18 13:08

I\'m doing some background work and showing a DialogFragment while I do that. Once my work is done and the relevant callback is invoked, I dismiss the dialog. When I do, I get a

6条回答
  •  抹茶落季
    2021-02-18 13:13

    Checking if it's Visible before dimissing could avoid this null pointer exception

        if (mDialog != null && mDialog.isVisible) {
            mDialog.dismiss();
            mDialog = null;
        }
    

提交回复
热议问题