2

Is it possible to track the origin of a deep link into an app? In my project, I’m successfully deep linking from the browser into my app, completing what I need to do, and then am wanting to be sent back to the browser. However, calling finish() doesn’t work because, for some reason, my home screen is the activity in the stack between my browser (where I clicked the deep link) and my app, so I end up just getting put back on my phone’s home screen.

My thought was to somehow identity the “caller” of the deep link. Is there a way to do this without passing, say, the user agent in the query params of the deep link?

Where I'm at right now is as follows:

var browser = "com.android.chrome"
var intent = packageManager.getLaunchIntentForPackage(browser)
startActivity(intent)

But, obviously, I'd need to know the name of the package of the browser they came from.

(Or if anyone knows why my deep link may be going [browser -> home screen -> app] instead of [browser -> app], that would also be helpful.)

This is the activity stack just before calling finish(), from running adb shell dumpsys activity | grep -i run:

 Running activities (most recent first):
        Run #0: ActivityRecord{50a3a82 u0 io.myapp/.activity.ActivityMain t6634}
    Running activities (most recent first):
        Run #0: ActivityRecord{b13082f u0 com.teslacoilsw.launcher/.NovaLauncher t6481}
    Running activities (most recent first):
        Run #0: ActivityRecord{c974ad u0 com.android.chrome/com.google.android.apps.chrome.Main t6607}

Where com.teslacoilsw.launcher/.NovaLauncher is my homescreen.

TheWhalePhail
  • 113
  • 1
  • 5

0 Answers0