0

I need to find out which app is launching a deep link into my app for security purposes

Has anyone done this before?

There are some solutions such as Using Pending intents to find creator package name but it didn't work for me.

Any ideas?

AndroidEnthusiast
  • 6,557
  • 10
  • 42
  • 56

1 Answers1

0

You can use getReferrer().getHost() to get the package name of the app that launched your app.

For example, if a link was launched from Google docs that launched your app, it would return com.google.android.apps.docs.editors.docs.

See Activity#getReferrer(), but as the doc notes, if an app wanted to spoof it or leave it empty, it could. So, not 100%.

Otherwise, resort to something like Get Recent and Running application list not processes and get the last app/activity before yours.

TWL
  • 6,228
  • 29
  • 65