在启动应用程序之前未收到INSTALL_REFERRER [英] INSTALL_REFERRER not received before application launched

查看:317
本文介绍了在启动应用程序之前未收到INSTALL_REFERRER的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在自己的接收方处接收INSTALL_REFERRER的意图. 我实现了接收器

I want to catch INSTALL_REFERRER intent at my own receiver. I implemented receiver

public class InstallReferrerReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
           Log.d("Broadcast", "RECEIVED!");
        }
}

并在清单上添加

<receiver
    android:name=".receiver.InstallReferrerReceiver"
    android:exported="true">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER"/>
    </intent-filter>
</receiver>

当我要测试接收器时,我安装我的应用程序(不启动)并通过adb发送广播

When i want to test receiver, i install my application(not launch) and send broadcast via adb

am broadcast -a com.android.vending.INSTALL_REFERRER --es "referrer" "utm_medium=partner&utm_campaign=partner_name"

但是看不到任何日志.沉默后,它可以正常工作并收到意图.

But can't see any logs. After lounch, it work correct and receive intents.

来自测试Google Play广告系列评估"

From "Testing Google Play Campaign Measurement"

要将INSTALL_REFERRER意图广播到您的应用程序:

To broadcast the INSTALL_REFERRER intent to your application:

  1. 验证您的应用程序当前未运行.
  2. 打开终端并运行以下命令:...

但是,在我第一次启动应用程序之前,我的接收者没有收到意图.这是正确的行为吗?当我收到来自市场的带有引荐来源网址参数的应用程序时会收到此意向吗?

But my receiver not receive intents, before i launch application first time. Is this a correct behavior? When i receive this intent if i install application from market with referrer params?

谢谢

推荐答案

在Android 3.1+应用程序的BroadcastReceiver(或任何其他组件)上,除非用户至少启动一次该应用程序,否则不会将其触发.在此之前,它处于停止"状态

On Android 3.1+ application's BroadcastReceiver (or any other component) will not be fired until user has launched the application at least once. Until then it is in the "stopped" state

是预期的行为,并且可以防止某些安全风险.

That is an intended behaviour and prevents some security risks.

这篇关于在启动应用程序之前未收到INSTALL_REFERRER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆