广播INSTALL_REFERRER意图问题意图、问题、INSTALL_REFERRER

2023-09-07 17:00:47 作者:俘虏

我的Andr​​oid清单文件

 <服务机器人:名字=com.google.android.gms.analytics.CampaignTrackingService/>      <接收机器人:名字=com.google.android.gms.analytics.CampaignTrackingReceiver            机器人:出口=真正的>            &所述;意图滤光器>                <作用机器人:名字=com.android.vending.INSTALL_REFERRER/>            &所述; /意图滤光器>      < /接收器> 

我没有任何其他接收机。

测试:

 〜/开发/ SDK /平台的工具$ ./adb外壳AM广播-a -n com.android.vending.INSTALL_REFERRER com.myapp.myapplication / com.google.android .gms.analytics.CampaignTrackingService --es引荐 \"utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign\" 

响应:

 广播:意向{行动= com.android.vending.INSTALL_REFERRER CMP = com.myapp.myapplication / com.google.android.gms.analytics.CampaignTrackingService(有临时演员)}广播结束:结果= 0 
linux下安装oracle的问题,在运行. runinstall的时候报错了,高手们看看吧

现在,当我运行应用程序,我得到了 I / GAV3(17797):螺纹[GAThread,5,主]:没有找到运动数据

然后我试图自定义接收器:这里是我的code:

 <服务机器人:名字=com.myapp.myapplication.ReferrerCatcher/><接收机器人:名字=com.myapp.myapplication.ReferrerCatcher机器人:出口=真正的>  &所述;意图滤光器>    <作用机器人:名字=com.android.vending.INSTALL_REFERRER/>  &所述; /意图滤光器>< /接收器> 

和我的接收器:

 包com.myapp.myapplication;进口android.content.BroadcastReceiver;进口android.content.Context;进口android.content.Intent;进口android.os.Bundle;进口android.util.Log;进口com.google.analytics.tracking.android.CampaignTrackingReceiver;公共类ReferrerCatcher扩展广播接收器{      私有静态字符串标记=INSTALL_RECEIVER;        @覆盖        公共无效的onReceive(上下文的背景下,意图意图){            Log.d(TAG,收到安装事件);            字符串引用=;            捆绑额外= intent.getExtras();            如果(临时演员!= NULL){                引用= extras.getString(推荐人);            }            Log.d(TAG的Referer是:+意图+::+临时演员);            新CampaignTrackingReceiver()的onReceive(上下文,意图)。        }} 

这是我的自定义接收机测试:〜/开发/ SDK /平台的工具$ ./adb外壳AM广播-a -n com.android.vending.INSTALL_REFERRER com.myapp.myapplication / com.myapp.myapplication.ReferrerCatcher --es引用 \"utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign\"

这是响应:

 广播:意向{行动= com.android.vending.INSTALL_REFERRER CMP = com.myapp.myapplication / .ReferrerCatcher(有临时演员)}广播结束:结果= 0 

现在,当我运行的应用程序,这是我所得到的:

  08-15 14:59:38.391:D / INSTALL_RECEIVER(24996):Referer的是:意向{行动= com.android.vending.INSTALL_REFERRER FLG = 0×10 = CMP com.myapp .myapplication / .ReferrerCatcher(有临时演员)} ::捆绑[{引用= utm_source = testSource}] 

这是比最后的测试但我没有得到完整的引荐更好。我刚开的来源。能否请您看看在code,看看我做任何错误?我一直在努力与此code,现在2天。

感谢您提前。

解决方案

短期和简单的答案。您必须连接code你的推荐人信息,或者你只得到了第一个参数。您可以更改则params的顺序,你仍然会得到第一个参数值。

utm_source%3DtestSource%26utm_medium%3DtestMedium%26utm_term%3DtestTerm%26utm_content%3DtestContent%26utm_campaign%3DtestCampaign

My Android Manifest file

<service android:name="com.google.android.gms.analytics.CampaignTrackingService" />
      <receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
            android:exported="true" >
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
      </receiver>

I don't have any other receiver.

Test:

 ~/development/sdk/platform-tools $ ./adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n com.myapp.myapplication/com.google.android.gms.analytics.CampaignTrackingService --es  "referrer" "utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign"

The response:

Broadcasting: Intent { act=com.android.vending.INSTALL_REFERRER cmp=com.myapp.myapplication/com.google.android.gms.analytics.CampaignTrackingService (has extras) }
Broadcast completed: result=0

Now when I run the app I get the I/GAV3(17797): Thread[GAThread,5,main]: No campaign data found.

Then I tried the custom receiver: Here is my code:

<service android:name="com.myapp.myapplication.ReferrerCatcher"/>
<receiver android:name="com.myapp.myapplication.ReferrerCatcher" android:exported="true">
  <intent-filter>
    <action android:name="com.android.vending.INSTALL_REFERRER" />
  </intent-filter>
</receiver>

And my receiver:

package com.myapp.myapplication;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.google.analytics.tracking.android.CampaignTrackingReceiver; 


public class ReferrerCatcher extends BroadcastReceiver {  

      private static String TAG = "INSTALL_RECEIVER"; 

        @Override
        public void onReceive(Context context, Intent intent) { 
            Log.d(TAG, "Received install event");
            String referrer = "";
            Bundle extras = intent.getExtras();
            if(extras != null) {
                referrer = extras.getString("referrer");
            }
            Log.d(TAG, "Referer is: " + intent + " :: " + extras );
            new CampaignTrackingReceiver().onReceive(context, intent); 
        }
}

And this is my test for the custom receiver: ~/development/sdk/platform-tools $ ./adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n com.myapp.myapplication/com.myapp.myapplication.ReferrerCatcher --es "referrer" "utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign"

And this is the response:

Broadcasting: Intent { act=com.android.vending.INSTALL_REFERRER cmp=com.myapp.myapplication/.ReferrerCatcher (has extras) }
Broadcast completed: result=0

Now when I run the app this is what I get:

08-15 14:59:38.391: D/INSTALL_RECEIVER(24996): Referer is: Intent { act=com.android.vending.INSTALL_REFERRER flg=0x10 cmp=com.myapp.myapplication/.ReferrerCatcher (has extras) } :: Bundle[{referrer=utm_source=testSource}]

Which is better than the last test however I am not getting the full referrer. I am just getting the source. Can you please have a look at the code and see if I am making any mistake? I have been struggling with this code for 2 days now.

Thank you in advance.

解决方案

Short and simple answer. You must encode your referrer information or you only get the first param. You can change the order of params and you'll still get the first param value.

utm_source%3DtestSource%26utm_medium%3DtestMedium%26utm_term%3DtestTerm%26utm_content%3DtestContent%26utm_campaign%3DtestCampaign