Android Navigation library deep linking: How to synthesise backstack

后端 未结 2 909
没有蜡笔的小新
没有蜡笔的小新 2021-02-05 13:45

Using Android Architecture\'s Navigation component, I have the following navigation graph

-> [Home] -> [Articles List] -> [Specific Article]

<
2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-05 14:24

    Per the NavDeepLinkBuilder documentation, Navigation uses the startDestination of the destination for the synthetic back stack. If you Group destinations into a nested navigation graph, both the startDestination of the nested graph and the startDestination of the root graph are added to the back stack. This gives you the ability to have [Articles List] as the startDestination of the nested graph to add it to your back stack.

    However, it is strongly recommended to keep your synthetic back stack as small as possible - while a depth of 2 or 3 (as here) is fine, it is not recommended to go much beyond that level to avoid cases where users have to repeatedly tap and tap the back button to get back to the launcher.

提交回复
热议问题