未收到安装引荐来源

时间:2014-12-08 16:39:27

标签: java android

我把它放在了android清单中:

</application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false">
     <receiver
     android:name="com.erl.aol.BroadcastReceiver"
     android:exported="true">
     <intent-filter>
         <action android:name="com.android.vending.INSTALL_REFERRER" />
     </intent-filter>
 </receiver>

这是我的java代码:

    package com.erl.aol.javaReferrerPlugin;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;


    public class PluginClass extends BroadcastReceiver {

        static String receivedReferrer = "";
        static String fullPath = "empty";



       @Override
             public void onReceive(Context context, Intent intent) {
            String referrer = intent.getStringExtra("referrer");
            receivedReferrer = referrer;
            fullPath = "full path found";       // do stuff with the referrer
        }

       public static String GetReffererString()
       {
           return receivedReferrer;
       }

       public static String HasEnteredOnReceive()
       {
           return fullPath;
       }

       public static String TestMethod()
       {
           return "This is a test string.";
       }
    }

我尝试在adb-shell中模拟广播,如下所示:

am broadcast -a "com.android.vending.INSTALL_REFERRER" -n “com.erl.aol/com.erl.aol.javaReferrerPlugin.PluginClass” -e "referrer" "deliveryId=testapp15sep&utm_medium=RANDOM58&utm_source=BroadcastTest"

但命令返回:

  

广播已完成:结果= 0

我没有在我的设备上获得推荐人。请注意,androidmanifest代码段只是实际清单的一部分,而我的应用包ID是

  

com.erl.aol

我做错了什么?

1 个答案:

答案 0 :(得分:0)

正确的命令是这样的: am broadcast -a com.android.vending.INSTALL_REFERRER --es referrer customReferrer com.erl.aol.javaReferrerPlugin

我假设您的推荐人在com.erl.aol.javaReferrerPlugin包中