I need to dismiss DialogFragment in onStop() of an FragmentActivity if it is showing, this is what I did
if(mAlertDlg != null && mAlertDlg.getDialog() != null)
mAlertDlg.dismiss();
But I usually got IllegalStateException. So please tell me why that code is wrong and what is the correct way to dismiss DialogFragment in onStop()? Thank you.
*****AllowingStateLoss()
methods to address issues like this. TheIllegalStateException
is thrown because state loss will occur. Using these methods are just avoiding the exception... but the state loss will still remain likely causing a bug in your application. – Siegfried