gpt4 book ai didi

android - 广播 INSTALL_REFERRER Intent 问题

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:10:29 31 4
gpt4 key购买 nike

我的 Android list 文件

<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>

我没有任何其他接收器。

测试:

 ~/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"

响应:

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

现在,当我运行该应用程序时,我得到了 I/GAV3(17797): Thread[GAThread,5,main]: No campaign data found。

然后我尝试了自定义接收器:这是我的代码:

<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>

还有我的接收器:

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);
}
}

这是我对自定义接收器的测试:~/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"

这是响应:

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

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

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}]

这比上次测试要好,但是我没有得到完整的推荐人。我只是得到来源。能否请您看一下代码,看看我是否犯了任何错误?我已经为这段代码苦苦挣扎了 2 天。

提前谢谢你。

最佳答案

简短的回答。您必须编码您的引荐来源信息,否则您只会获得第一个参数。您可以更改参数的顺序,您仍然会获得第一个参数值。

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

关于android - 广播 INSTALL_REFERRER Intent 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25321521/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com