2

I have activity A that defines androidx.fragment.app.FragmentContainerView with given navGraph in its layout. Starting point of nav graph is fragment F1 that has action to navigate to fragment F2 (action only has id and destination). Fragment F2 has action with id and popupTo that specifies graph id of F1. This all works great until I change activity orientation by flipping device. After orientation change, when I execute F2 action, I get java.lang.IllegalStateException: no current navigation node Why this happens and how to fix?

UPDATE: nav components bug. Solution here: <androidx.fragment.app.FragmentContainerView> vs <fragment> as a view for a NavHost

ror
  • 3,295
  • 1
  • 19
  • 27

1 Answers1

0

This might be due to the fragment state changes after the orientation has changed. You can use "setRetainInstance(true)" in the onCreate() of fragments to keep their state save for orientation changes.

  • I wasn't doing any orientation change but even if I would, retaining instance looks more like workaround than a solution. – ror Dec 04 '19 at 08:03
  • But you said above that you change your activity orientation by flipping the device, after that it is showing you exception. Please make sure what you've asked or what didn't. – Satyam Kamboj Dec 04 '19 at 15:09
  • Sorry I apologize – ror Dec 04 '19 at 15:31