Android Navigation Url Deep Link Back to Previous App
Asked Answered
F

1

3

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!")
}
Fieldpiece answered 4/11, 2020 at 20:53 Comment(2)
Did you find a good solution?Citrus
@Citrus Still no, sorry.Fieldpiece
B
0

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.

Buckling answered 8/11, 2020 at 17:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.