Home > database >  Android navigation component, backstack, nav graph, skip fragments
Android navigation component, backstack, nav graph, skip fragments

Time:11-05

I have following navigation in app.

A->B->X->Y->R

or

A->C->X->Y->R

or

A->X->Y->R

or

A->R

I don't want X and Y in backstack.

I know than in action Y->R I can do something like this:

        app:popUpTo="@id/B"
        app:popUpToInclusive="true"

or

        app:popUpTo="@id/C"
        app:popUpToInclusive="true"

But I don't want to pass param to X and Y and do separate action to go back to B or C. There must be a smarter way to do that.

CodePudding user response:

In your action from Y->R, you can add:

app:popUpTo="@id/X"
app:popUpToInclusive="true"

This will pop everything till X (including X) and you will get your desired backstack.

  • Related