拦截 INSTALL_REFERRER 然后转发到 Google AnalyticsReceiver

发布于 2024-10-17 13:40:54 字数 529 浏览 3 评论 0原文

我编写了一个安装接收器来确定应用程序何时通过市场安装。但是,我还想将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ぺ禁宫浮华殁 2024-10-24 13:40:54

这并不能真正回答问题,但 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:

去了角落 2024-10-24 13:40:54

罗曼的回答并不完全正确。他们没有提供一步一步的说明,但谷歌本身建议如果需要的话使用您自己的广播接收器。我确实认为他们最近添加了这个简介,但不确定是什么时候。当我回答他链接的问题之一时,我非常肯定它不存在。

来自他们的指南

注意:每个广播接收器只能指定一个类
应用。如果您需要合并两个或多个
来自不同 SDK 的广播接收器,您需要创建自己的
自己的 BroadcastReceiver 类将接收所有广播并调用
每种类型的广播的适当的广播接收器。

这似乎也回答了是否可以盲目重新广播的问题,至少根据谷歌的说法。

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:

Note: Only one BroadcastReceiver class can be specified per
application. Should you need to incorporate two or more
BroadcastReceivers from different SDKs, you will need to create your
own BroadcastReceiver class that will receive all broadcasts and call
the appropriate BroadcastReceivers for each type of Broadcast.

This also seems to answer the question of whether you can blindly re-broadcast, at least according to Google.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文