'Android navigation fragment: other fragment is blank screen

The next screen does not come up when navigating between fragments. It exits fragment a but does not go to b. When I inspect the profiler it says I'm in fragment b.

Sometimes it happens when switching fast or when new data arrives. Nothing shows up in the logs.

When I switch between apps, the white screen goes back to normal.

Error Video

OtherFragment -> AFragment

val action = OtherFragmentDirections.actionOtherFragmentToA()
Navigation.findNavController(requireActivity(), R.id.main_fragmentContainerView)
    .navigate(action)

AFragment -> OtherFragment

val action = ADirections.actionAFragmentToOtherFragment()
Navigation.findNavController(requireActivity(), 
              R.id.main_fragmentContainerView).navigate(action)

The problem has been going on for a long time because it does not fall into the logs. Could it be related to LiveData, ViewModel or Hilt?



Solution 1:[1]

If you are using nav graph then you are try to call another fragment like

 findNavController(R.id.nav_host_fragment).navigate(
                R.id.your_next_fragment)

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 Yash Shah