1

App package name A, send intent with action ACTION_VIEW and url data to system, app B get it and open, but I just want B open intent and don't want app B get app A's package name, How to do it?

candrwow
  • 511
  • 5
  • 21

1 Answers1

1

The only way to find out the package that sent the Intent seems to be via Acitvity#getReferrer() (taken from this SO post). In its docs, the following is clearly stated

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 Intent#URI_ANDROID_APP_SCHEME 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.

Hence you can add Intent.EXTRA_REFERRER to the intents you're sending to override the default value.


Ref

  1. https://stackoverflow.com/a/37761737
  2. https://developer.android.com/reference/android/app/Activity#getReferrer()
  3. https://developer.android.com/reference/android/content/Intent#EXTRA_REFERRER
ashu
  • 1,756
  • 4
  • 22
  • 41