Rik van Velzen
Rik van Velzen

Reputation: 2015

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

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?

Upvotes: 2

Views: 991

Answers (1)

Rik van Velzen
Rik van Velzen

Reputation: 2015

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

setRetainInstance(true);

Removing this solved it.

Upvotes: 4

Related Questions