Android NavController: How to solve saveBackStack must not contain retained fragment

Viewed 242

I am trying create deeplinks to specific screens via incoming push notifications on our Android app by calling NavController.handleDeeplink(intent).

But when the app tries to navigate to the specific Fragment an exceptionis thrown:

java.lang.IllegalArgumentException: saveBackStack("95f6209a-b0e7-46f9-a37e-6c01ee5fb1fc") must not contain retained fragments. Found direct reference to retained fragment xxxFragment{a0041f} (f8f7126e-5402-4ab2-b14f-7a656480d3f7 id=0x7f0a03a5)

Anyone any pointers on how to solve this?

1 Answers

In my case used Fragments in the app where inhereting from a BaseFragment that where calling the deprecated:

setRetainInstance(true);

Removing this solved it.

Related