是否可以通过 Intent 找出哪个应用与我的应用共享了某些内容?

Is it possible to find out which app shared something with my app via an Intent?

我有一个视频播放器应用程序,并且有一些应用程序可以与我的应用程序共享视频。从技术上讲,任何通过 Intent 共享视频的应用程序都可以与我的应用程序共享它,但我的应用程序接受一些更复杂的选项,某些应用程序也会通过。

我想知道我的应用程序是否有办法知道发送 Intent 的是哪个应用程序?

不,目前不可能

如果发件人在意图中保留了额外的字段,您只能确定发件人的来源。

更多详情,您可以查看这里 -> How to get the sender of an Intent?

实际上 Activity 中有一个 referrer(自 API 22 起),这不是 100% 保证,但我已经在应用程序中使用过它并且效果很好。这是它的docs

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.

您可以在 Java 中使用 Activity.getRefferer() 或在 Kotlin

中使用 referrer 来获取它