Let's say I have three fragments, A, B, C;
A -> B <-> C
Between B and C it is a circular relationship. Either B or C fragments requires arguments
, example
val args = Bundle()
args.putString("StringKeyBC", argValueBtoC)
findNavController().navigate(R.id.action_fragmentB_to_fragmentC, args, null)
args.putString("StringKeyCB", argValueCtoB)
findNavController().navigate(R.id.action_fragmentC_to_fragmentB, args, null)
The problem is that every time I move between B & C, the fragments are added to back stack and I don't want that. If the fragment is already to back stack I want just to pop it, but if I use popBackStack
I can not add arguments anymore:
public boolean popBackStack(@IdRes int destinationId, boolean inclusive)
So, how can I constanlty switch between the two fragments without adding them every time to back stack?