Android Navigation Url Deep Link Back to Previous App

主宰稳场 提交于 2020-11-25 03:42:17

问题


My app has just two destinations, FirstFragment and SecondFragment. I created an url Deep Link for the SecondFragment and it works fine.

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.

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!")
}

回答1:


The DeepLink knows about your NavGraph. And if your SecondFragment is a decendent of the FirstFragment, this is the intended behavior.

When you show your NavGraph and how you create the DeepLink it might be possible to suggest a different option.



来源:https://stackoverflow.com/questions/64687574/android-navigation-url-deep-link-back-to-previous-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!