拦截 INSTALL_REFERRER 然后转发到 Google AnalyticsReceiver
我编写了一个安装接收器来确定应用程序何时通过市场安装。但是,我还想将 INSTALL_REFERRER 广播传递到其他接收器,例如 Google Analytics AnalyticsReceiver
(如果它安装在应用程序中)。重要的是,我不知道是否安装了其他接收器,因为我的接收器将被其他开发人员在他们的应用程序中使用。
目前,我收到广播,完成后我调用:
AnalyticsReceiver receive = new AnalyticsReceiver();
receiver.onReceive(context, Intent);
问题是 AnalyticsReceiver
类可能不存在。
那么,如果我不确定应用是否使用 AnalyticsReceiver
,我该如何传递广播?
或者 Android 本身会确保安装的每个接收器都能获取广播?
非常感谢!
I have written an install receiver to determine when an app has been installed via the Market. However, I also want to pass the INSTALL_REFERRER broadcast onto other receivers such as the Google Analytics AnalyticsReceiver
if it is installed within the app. Importantly, I do NOT know if other receivers are installed as my receiver will be used by other developers within their apps.
Currently, I receive the broadcast and when complete I call:
AnalyticsReceiver receiver = new AnalyticsReceiver();
receiver.onReceive(context, intent);
The issue is the AnalyticsReceiver
class may not be present.
So how do I pass on the broadcast if I'm not sure whether the app uses the AnalyticsReceiver
?
Or will Android itself make sure each receiver installed gets the broadcast?
Many thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这并不能真正回答问题,但
INSTALL_REFERRER
的唯一预期目的地是 Google Analytics 库,因此对于广播中包含的数据(或与该广播有关的任何内容)的保证为零重要),所以你不应该依赖它。顺便说一句,这里有一些相关的 SO 问题:
This doesn't really answer the question, but the only intended destination for
INSTALL_REFERRER
is the Google Analytics library, and thus there are zero guarantees about the data contained in the broadcast (or anything about the broadcast for that matter), so you shouldn't rely on it.On a side note, here are some related S.O. questions:
罗曼的回答并不完全正确。他们没有提供一步一步的说明,但谷歌本身建议如果需要的话使用您自己的广播接收器。我确实认为他们最近添加了这个简介,但不确定是什么时候。当我回答他链接的问题之一时,我非常肯定它不存在。
来自他们的指南:
这似乎也回答了是否可以盲目重新广播的问题,至少根据谷歌的说法。
Roman's answer is not entirely correct. They don't go into step by step instructions, but Google themselves recommend using your own broadcast receiver if you need to. I do think they added this blurb recently, but not sure when. I'm pretty positive it did not exist when I answered one of the questions he links.
From their guide:
This also seems to answer the question of whether you can blindly re-broadcast, at least according to Google.