0

I'm migrating my code to the new Nav libraries, but I want some equivalent to commitAllowingStateLoss like there is in FragmentTransaction. Any tips?

Thanks in advance!

Saba Imran
  • 201
  • 2
  • 11
  • No, but you can check this https://medium.com/inloopx/demystifying-androids-commitallowingstateloss-cb9011a544cc – Chisko Jun 19 '18 at 00:31
  • There is no equivalent to `commitAllowingStateLoss` - Navigation always uses `commit`. What is your use case for using `commitAllowingStateLoss`? – ianhanniballake Jun 19 '18 at 05:09
  • 1
    I'm getting an IllegalStateException: Can not perform this action after onSaveInstanceState. I've seen elsewhere that a workaround to this error is to use commitAllowingStateLoss(), which I previously had in my code. Not sure how to make it parallel with the Nav libraries. – Saba Imran Jun 19 '18 at 17:39

1 Answers1

0

This error was occurring because I was loading a new Fragment inside of the activity, outside of the Navigation graph. I was then calling findNavController().navigate() after this, causing state loss.

Saba Imran
  • 201
  • 2
  • 11