https://kotlinlang.org logo
#compose
Title
# compose
c

Chris Fillmore

07/28/2021, 6:46 PM
Can anyone advise on how to trigger a deep link to an Activity which is already in the back stack? Currently I have some code like:
Copy code
val intent = Intent(Intent.ACTION_VIEW, myDeepLinkUri, context, MyAlreadyRunningActivity::class.java).apply {
  addFlags(
    Intent.FLAG_ACTIVITY_CLEAR_TOP or
    Intent.FLAG_ACTIVITY_SINGLE_TOP or
    Intent.FLAG_ACTIVITY_NEW_TASK
  )
}
TaskStackBuilder
  .create(context).apply {
    addNextIntentWithParentStack(intent)
  }
  .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)
  ?.send()
However, doing this starts a new Activity, which I don’t want. Previously I was just using
startActivity(intent)
but this didn’t trigger the deep link. Has anyone handled this? Thanks for the help!