I am using a AppCompatDialogFragment
. My dialogFragment is not dismissed in some scenario.
The scenario flow is
- Showing the dialogFragment
- dialogFragment UI has a Button.In button click a api is called and after api response i dismiss the dialog and set an myObject to null as i don't need that object.
- Then i show second dialog and user manually dismiss this dialog
- After dismissing second dialog users are able to interact(click on that button) with first dialogFragment
I am getting a crash on dialogFragment button click for null object reference on myObject which i previously set to null.
User is able to click button after dialogFragment dismiss call. As i have set myObject to null first time so i'm getting Exception.But user shouldn't able to click second time as i have called dismiss().
I can't generate this Exception and its happening in live in some cases and i have traced the scenario with Crash Log
Crash happens only when user are able to click second time
Why the dialogFragment is not dismissing some case? I am using dialogFragment.dismiss()
method for dismiss.
Is this happening for state loss issue? But i think for state loss issue i should get a Exception for IllegalStateException
A workaround may be getSupportFragmentManager().executePendingTransactions()
.
Any one can explain the scenario ? why this happening or how to solve this.
Thanks in Advance