Skip to content Skip to sidebar Skip to footer

Fragment Created Twice With Navigation Controller

In the app, we start a new activity holding a fragment, let's call it A. Recently navigation component was added and transitions follow the navigation graph. So initially it is sta

Solution 1:

I finally found the answer, instead of navigating back to the fragment you want, you need to pop them from the backstack. This doesnt create new instances and the lifecycle is correct.

findNavController().popBackStack(R.id.nav_something_fragment, false)

Finally also saw this answer which says the same

Post a Comment for "Fragment Created Twice With Navigation Controller"