1

I have a video player app and there are a few apps out there that share videos with my app. Technically any app that shares a video via a Intent can share it with my app but there are a few more complex options my app accepts that some apps will also pass.

I would like to know if there is a way for my app to know which was the app that sent the Intent?

casolorz
  • 8,486
  • 19
  • 93
  • 200
  • do you want to know the app among all the app which can share video with your app or you just want to know the name among the app which knows about more complex options of your app? – Dinkar Kumar May 15 '21 at 14:11
  • I want to know any app that shared with mine no matter what, but I would settle for those that pass more specific extras. – casolorz May 15 '21 at 22:05
  • let me try few POC and get back to you if I can find anything that can be useful to you – Dinkar Kumar May 16 '21 at 05:22
  • Most commonly most of the standard apps send the package of the app in Intent extras so you can check the extras of the intent there you will get the package name. – Shivam Yadav May 16 '21 at 07:42

2 Answers2

4

Actually there is a referrer in Activity (since API 22) which is not 100% guaranteed but I've used it in an app and it works great. Here is the docs for it.

Return information about who launched this activity. If the launching Intent contains an Intent.EXTRA_REFERRER, that will be returned as-is; otherwise, if known, an android-app: referrer URI containing the package name that started the Intent will be returned. This may return null if no referrer can be identified -- it is neither explicitly specified, nor is it known which application package was involved.

You can get it using Activity.getRefferer() in Java or simply referrer in Kotlin

Amin
  • 3,056
  • 4
  • 23
  • 34
1

No, currently it's not possible

You can only determine the origin of the sender if the sender kept an extra field in intent.

For more details, you can check this -> How to get the sender of an Intent?

AgentP
  • 6,261
  • 2
  • 31
  • 52