'navigateUp() and popBackStack() not working. Instead, they reload the current fragment
I am trying to navigate up the backstack. On calling the method view?.findNavController().navigateUp()
and logging the destination using view?.findNavController().getCurrentDestination()
, I see the function popping the current destination and then reloading it again. I don't understand why this could be happening yet I am doing the same in other fragments and it's working.
Solution 1:[1]
The issue came up because I was using LiveData to trigger the navigation. To avoid the issue, I have had to update the MutableLiveData before navigating so that it does not request to navigate back when I navigateUp from the destination.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mutevu |