Friday, 28 June 2019

Kill fragment in navigation controller

My flow of fragment is like this

Main -> A -> B -> C ->A

In fragment c, it has a submit button which will return to A. When I press back button in A, I want it back to Main. But it return to fragment c instead.

In fragment C, I use this

 findNavController().navigate(R.id.action_c_to_a)

nav_graph.xml

 <fragment
        android:id="@+id/fragmentC"
        android:name="xxx"
        android:label="xxx">
        <action
            app:launchSingleTop="true"
            app:popUpTo="@+id/fragmentA"
            app:popUpToInclusive="true"
            android:id="@+id/action_c_to_a"
            app:destination="@id/fragmentA" />
    </fragment>



from Kill fragment in navigation controller

No comments:

Post a Comment