我无法测试INSTALL_REFERER广播接收器

时间:2014-04-04 10:47:16

标签: android android-manifest android-broadcast

首先抱歉我的英语不好,我正在改进它。

我正在尝试测试INSTALL_REFERER boradcast,但我无法使其正常工作。

我的包裹:

es.beedroid.beebubble

我的清单中的接收者是:

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

为了测试那个接收器,我做了这个:

static void displayMessage(Context context, String message) {

    Intent i = new Intent("com.android.vending.INSTALL_REFERRER");
//      i.setPackage("es.beedroid.beebubble");

    i.putExtra("referrer", "&huevos=hola");
    context.sendBroadcast(i);
}

但是当我启动应用程序时,我收到以下错误:

04-04 12:46:05.432: E/AndroidRuntime(20996): FATAL EXCEPTION: main
04-04 12:46:05.432: E/AndroidRuntime(20996): java.lang.RuntimeException: Unable to instantiate     receiver es.beedroid.beebubble.Load$InstallReferrerReceiver: java.lang.InstantiationException: es.beedroid.beebubble.Load$InstallReferrerReceiver
04-04 12:46:05.432: E/AndroidRuntime(20996):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:1874)
04-04 12:46:05.432: E/AndroidRuntime(20996):    at android.app.ActivityThread.access$2400(ActivityThread.java:156)
04-04 12:46:05.432: E/AndroidRuntime(20996):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1050)
04-04 12:46:05.432: E/AndroidRuntime(20996):    at android.os.Handler.dispatchMessage(Handler.java:130)
04-04 12:46:05.432: E/AndroidRuntime(20996):    at android.os.Looper.loop(SourceFile:351)
04-04 12:46:05.432: E/AndroidRuntime(20996):    at android.app.ActivityThread.main(ActivityThread.java:3821)
04-04 12:46:05.432: E/AndroidRuntime(20996):    at java.lang.reflect.Method.invokeNative(Native Method)
04-04 12:46:05.432: E/AndroidRuntime(20996):    at java.lang.reflect.Method.invoke(Method.java:538)
04-04 12:46:05.432: E/AndroidRuntime(20996):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969)
04-04 12:46:05.432: E/AndroidRuntime(20996):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727)
04-04 12:46:05.432: E/AndroidRuntime(20996):    at dalvik.system.NativeStart.main(Native Method)
04-04 12:46:05.432: E/AndroidRuntime(20996): Caused by: java.lang.InstantiationException: es.beedroid.beebubble.Load$InstallReferrerReceiver
04-04 12:46:05.432: E/AndroidRuntime(20996):    at java.lang.Class.newInstanceImpl(Native Method)
04-04 12:46:05.432: E/AndroidRuntime(20996):    at java.lang.Class.newInstance(Class.java:1440)
04-04 12:46:05.432: E/AndroidRuntime(20996):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:1865)
04-04 12:46:05.432: E/AndroidRuntime(20996):    ... 10 more

为什么呢?有没有其他方法来测试该功能?我尝试用adb测试它但它不起作用(它永远不会通过接收器)。

adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n     es.beedroid.beebubble/.com.beedroid.activities.Load$InstallReferrerReceiver --es "referrer"     "utm_source=test_source&utm_medium=test_medium&utm_term=test_term&utm_content=test_content&utm_campaign=test_name"

1 个答案:

答案 0 :(得分:1)

尝试将 ./ 添加到adb并使用以下

./adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n es.beedroid.beebubble/es.beedroid.beebubble.Load$InstallReferrerReceiver --es "referrer" "utm_source=test_source&utm_medium=test_medium&utm_term=test_term&utm_content=test_content&utm_campaign=test_name"

还有我已经移除的白色空间,你的路径说

.com.beedroid.activities.Load$InstallReferrerReceiver

我觉得应该

es.beedroid.beebubble.Load$InstallReferrerReceiver

如果它确实有效,请告诉我,因为我使用相同的方式调试了它。

注意 - 当您从终端点击此按钮时,应该 NOT 正在运行。

快乐编码:)