I am getting the well known java.lang.IllegalArgumentException: View not attached to window manager
. The currently known solution is to ignore the error using empty try-catch block. But is it there a more programmer friendly solution? E.g.
if (dialog.isAttached())
dialog.dismiss();
Of course, better would be if the Android SDK would have a not failing function (because why the API should fail if it is impossible to avoid it??):
dialog.tryDismiss();
Or is the empty try-catch block architectonically justifiable? Or is it just a workaround for a bad or incomplete API?
I always use:
if(dialog != null && dialog.isShowing())
dialog.dismiss();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With