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!")
}
Sam Chen
  • 7,597
  • 2
  • 40
  • 73

1 Answers1

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.

Tobi
  • 858
  • 7
  • 15