From e77ea50087aecd2629f1f8ae66d1ed028ea7a5cb Mon Sep 17 00:00:00 2001 From: Nic Capdevila Date: Mon, 28 Nov 2016 18:21:27 -0800 Subject: [PATCH] - adding catch in case trying to show a dialog fragment and the activity closes --- .../main/java/com/ncapdevi/fragnav/FragNavController.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frag-nav/src/main/java/com/ncapdevi/fragnav/FragNavController.java b/frag-nav/src/main/java/com/ncapdevi/fragnav/FragNavController.java index d68fbde5..36818bbb 100644 --- a/frag-nav/src/main/java/com/ncapdevi/fragnav/FragNavController.java +++ b/frag-nav/src/main/java/com/ncapdevi/fragnav/FragNavController.java @@ -622,7 +622,11 @@ public void showDialogFragment(DialogFragment dialogFragment) { } mCurrentDialogFrag = dialogFragment; - dialogFragment.show(fragmentManager, dialogFragment.getClass().getName()); + try { + dialogFragment.show(fragmentManager, dialogFragment.getClass().getName()); + } catch(IllegalStateException e){ + // Activity was likely destroyed before we had a chance to show, nothing can be done here. + } } }