【问题标题】:Android Navigation Url Deep Link Back to Previous AppAndroid Navigation Url Deep Link Back to Previous App
【发布时间】:2021-02-17 14:10:35
【问题描述】:

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

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

我已在 launchMode 上将我的 MainActivity 设置为 singleTask 并尝试了以下操作但不起作用:

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

    intent!!.flags = Intent.FLAG_ACTIVITY_NEW_TASK

    navController.handleDeepLink(intent)

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

【问题讨论】:

    标签: android deep-linking android-jetpack android-navigation android-deep-link


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-26
      • 2023-03-03
      • 2020-06-22
      • 1970-01-01
      • 2020-09-05
      • 1970-01-01
      相关资源
      最近更新 更多