Android导航网址深层链接返回上一个应用 [英] Android Navigation Url Deep Link Back to Previous App
问题描述
我的应用只有两个目的地,即 FirstFragment 和 SecondFragment .我为 SecondFragment 创建了一个网址深度链接,并且效果很好.
My app has just two destinations, FirstFragment and SecondFragment. I created an url Deep Link for the SecondFragment and it works fine.
我想要的是,当我从深度链接输入 SecondFragment 之后,我想在按后退"按钮时返回上一个应用程序.但是现在,它总是回到 FirstFragment .
What I want is, after I enter the SecondFragment from the Deep Link, I want to go back to the previous app when I press the Back button. But now it always go back to the FirstFragment.
我已在 launchMode
上将 MainActivity 设置为 singleTask
,并尝试了以下操作,但不起作用:
I have set my MainActivity to singleTask
on launchMode
and tried the following but doesn't work:
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
intent!!.flags = Intent.FLAG_ACTIVITY_NEW_TASK
navController.handleDeepLink(intent)
Log.v("MainActivity", "onNewIntent() get called!")
}
推荐答案
DeepLink知道您的NavGraph.而且,如果您的SecondFragment是FirstFragment的后继者,则这是预期的行为.
The DeepLink knows about your NavGraph. And if your SecondFragment is a decendent of the FirstFragment, this is the intended behavior.
当您显示NavGraph以及如何创建DeepLink时,可能会建议其他选项.
When you show your NavGraph and how you create the DeepLink it might be possible to suggest a different option.
这篇关于Android导航网址深层链接返回上一个应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!