所以我使用的是 android 导航组件,但我遇到了问题(2.2.0-rc04 版本)。
我有一个welcomeFragment(wF)。从wF我想导航到loginSellerFragment不同导航图中的 (lSF)。我也不想wF在导航到时从 backstack (popUpTo, popUpToInclusive) 中删除,lSF因为用户可能想回到它。
<fragment
android:id="@+id/welcomeFragment">
<action
android:id="@+id/action_welcomeFragment_to_nav_onboarding_seller"
app:launchSingleTop="true"
app:destination="@id/nav_onboarding_seller" />
</fragment>
Run Code Online (Sandbox Code Playgroud)
导航到 lSF 后,backstack 如下所示:wF lSF
我们lSF现在开始,登录后我们想转到feedFragment(fF) ,它再次位于单独的图表中,但这次我们想清除所有后台堆栈,因为如果用户登录并按回,他希望应用程序退出,不是为了带他回到wFor lSF,所以我popUpTo="@id/loginSellerFragment popUpToInclusive='true"在动作中使用了lSFto fF。
<fragment
android:id="@+id/loginSellerFragment">
<action
android:id="@+id/action_login_to_seller"
app:destination="@+id/seller" . //this is the graph that has as firstDestination, feedFragment
app:launchSingleTop="true"
app:popUpTo="@id/loginSellerFragment"
app:popUpToInclusive="true" />
</fragment>
Run Code Online (Sandbox Code Playgroud)
所以在这个时刻的 backstack 应该只有fF因为我们删除了所有的东西lSF(lSF包括) …