WAI
Status Update
Comments
il...@google.com <il...@google.com> #2
It is working as intended that passing a deep link without the NEW_TASK flag resets the task stack (the setPopUpTo(mGraph.getId(), true)) before navigating to only the final destination.
See the previously filed issues:https://issuetracker.google.com/issues?q=componentid:409828%20status:intended_behavior%20NEW_TASK
Note that if your root graph does not have an ID, this is currently functioning incorrectly (nothing gets popped) - that work is being tracked inhttps://issuetracker.google.com/issues/126251695
See the previously filed issues:
Note that if your root graph does not have an ID, this is currently functioning incorrectly (nothing gets popped) - that work is being tracked in
Description
Version used: 1.0.0-rc01 and 1.0.0-beta02
Devices/Android versions reproduced on: any
I have nested navigation graph such as
<navigation
android:id="@+id/main"
app:startDestination="@+id/main">
...
<navigation
android:id="@+id/second"
app:startDestination="@+id/second">
...
<navigation
android:id="@+id/third"
app:startDestination="@+id/third">
...
<fragment
android:id="@+id/third">
<deepLink app:uri="deeplink://sample" />
</fragment>
</navigation>
</navigation>
</navigation>
When I handle deeplink, I clear flag FLAG_ACTIVITY_NEW_TASK, because it is product requirement, in code of navcontroller i see this code:
public boolean handleDeepLink(@Nullable Intent intent) {
...
NavGraph graph = mGraph;
for (int i = 0; i < deepLink.length; i++) {
int destinationId = deepLink[i];
NavDestination node = i == 0 ? mGraph : graph.findNode(destinationId);
if (node == null) {
throw new IllegalStateException("unknown destination during deep link: "
+ NavDestination.getDisplayName(mContext, destinationId));
}
if (i != deepLink.length - 1) {
// We're not at the final NavDestination yet, so keep going through the chain
graph = (NavGraph) node;
// Automatically go down the navigation graph when
// the start destination is also a NavGraph
while (graph.findNode(graph.getStartDestination()) instanceof NavGraph) {
graph = (NavGraph) graph.findNode(graph.getStartDestination());
}
} else {
// Navigate to the last NavDestination, clearing any existing destinations
navigate(node, node.addInDefaultArgs(bundle), new NavOptions.Builder()
.setPopUpTo(mGraph.getId(), true)
.setEnterAnim(0).setExitAnim(0).build(), null);
}
}
...
}
the variable "graph" created, but never used, and I clear my backstack not to "second", but to "main", and i cannot leave "third" screen after by press back button. I think .setPopUpTo() should use not mGraph.getId(), but graph.getId(). As long as it works as I wrote above, I have to use single navigation graph, and it is very bad solution.