2

我的应用程序只有两个目的地,FirstFragmentSecondFragment我为SecondFragment创建了一个 url 深层链接,它工作正常。

我想要的是,在我从 Deep Link 进入SecondFragment后,当我按下 Back 按钮时,我想回到上一个应用程序。但现在它总是回到FirstFragment

我已将MainActivity设置为singleTaskonlaunchMode并尝试了以下操作但不起作用:

override fun onNewIntent(intent: Intent?) {
    super.onNewIntent(intent)

    intent!!.flags = Intent.FLAG_ACTIVITY_NEW_TASK

    navController.handleDeepLink(intent)

    Log.v("MainActivity", "onNewIntent() get called!")
}
4

1 回答 1

0

DeepLink 了解您的 NavGraph。如果您的 SecondFragment 是 FirstFragment 的后代,那么这就是预期的行为。

当您展示您的 NavGraph 以及您如何创建 DeepLink 时,可能会建议一个不同的选项。

于 2020-11-08T17:13:54.233 回答