https://kotlinlang.org logo
#navigation-architecture-component
Title
# navigation-architecture-component
t

Tepes Lucian Victor

09/03/2021, 4:11 PM
I’ve started a new project using navigation component multiple backstack support and i’ve hit an issue with having an auth subgraph
Copy code
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="<http://schemas.android.com/apk/res/android>"
    xmlns:app="<http://schemas.android.com/apk/res-auto>"
    android:id="@+id/main"
    app:startDestination="@id/graph1">

    <include app:graph="@navigation/graph1" />
    <include app:graph="@navigation/graph2" />
    <include app:graph="@navigation/graph3" />

    <include app:graph="@navigation/auth" />

    <action
        android:id="@+id/action_to_auth"
        app:destination="@id/auth"
        app:popUpTo="@id/graph1"
        app:popUpToInclusive="true"
        app:launchSingleTop="true" />

    <action
        android:id="@+id/action_to_main"
        app:destination="@id/graph1"
        app:popUpTo="@id/auth"
        app:popUpToInclusive="true"
        app:launchSingleTop="true" />
</navigation>
When starting the app if the user is logged out i redirect to auth flow using the `action_to_auth`and when he logs out, i’m calling
navigate(R.id.action_to_auth)
. The issue with multiple backstacks is that saved stacks aren’t cleared and there is no way to query what back stacks were previously saved into the fragment manager.