From 46f2db427c03e072e35eb49ce9f8242fb440d44c Mon Sep 17 00:00:00 2001 From: wen Date: Wed, 21 Apr 2021 10:43:22 +0800 Subject: [PATCH] fix Cannot setMaxLifecycle for Fragment not attached to FragmentManager --- .../java/androidx/navigation/fragment/FragmentNavigator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/navigation-fragment/src/main/java/androidx/navigation/fragment/FragmentNavigator.java b/navigation-fragment/src/main/java/androidx/navigation/fragment/FragmentNavigator.java index 7fcdedf..ca4d583 100644 --- a/navigation-fragment/src/main/java/androidx/navigation/fragment/FragmentNavigator.java +++ b/navigation-fragment/src/main/java/androidx/navigation/fragment/FragmentNavigator.java @@ -196,7 +196,7 @@ public void onAnimationRepeat(Animation animation) { } private void performPopBack(Fragment preFrag) { - if (preFrag != null) { + if (preFrag != null && !preFrag.isDetached()) { mFragmentManager.beginTransaction().setMaxLifecycle(preFrag, Lifecycle.State.RESUMED).commit(); } mFragmentManager.popBackStack(