Android - 是否有可能以编程方式获取安装引荐 [英] Android - Is it possible to get install referrer programmatically

查看:157
本文介绍了Android - 是否有可能以编程方式获取安装引荐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到浏览器中的一些Google Play应用链接对他们来说具有 referrer = 属性,这显然会告诉转介者将您发送到Google Play中该应用的页面。

是否有可能在我的应用程序的代码中看到引用者(如果有)?如果没有,在任何地方都可以看到它? 可以使用 com.android.vending .INSTALL_REFERRER b
$ b


Google Play com.android.vending.INSTALL_REFERRER意图是当从Google Play商店安装应用程序时广播的


将此接收器添加到AndroidManifest.xml

 < receiver 
android:name =com.example.android.InstallReferrerReceiver
android:exported =true
android:permission =android.permission.INSTALL_PACKAGES >
< intent-filter>
< / intent-filter>
< / receiver>

创建BroadcastReceiver:

  public class InstallReferrerReceiver extends BroadcastReceiver {
@Override $ b $ public void onReceive(Context context,Intent intent){
String referrer = intent.getStringExtra(referrer);

//使用引用者


$ / code>

您可以按照此答案的步骤来测试引荐跟踪。


I have noticed some Google Play app links in the browser has the referrer= attribute to them, which obviously tells the referrer that sent you to that app's page in Google Play.

Is it possible to see that referrer (if any) in the code of my app? And if not, to see it anywhere at all?

解决方案

You can use com.android.vending.INSTALL_REFERRER.

The Google Play com.android.vending.INSTALL_REFERRER Intent is broadcast when an app is installed from the Google Play Store.

Add this receiver to AndroidManifest.xml

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

Create a BroadcastReceiver:

public class InstallReferrerReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String referrer = intent.getStringExtra("referrer");

        //Use the referrer
    }
}

You can test the referral tracking following the steps of this answer.

这篇关于Android - 是否有可能以编程方式获取安装引荐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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