Android - 是否有可能以编程方式安装引荐来源网址

Android - Is it possible to get install referrer programmatically(Android - 是否有可能以编程方式安装引荐来源网址)
本文介绍了Android - 是否有可能以编程方式安装引荐来源网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到浏览器中的一些 Google Play 应用链接具有 referrer= 属性,这显然告诉引荐来源网址将您发送到 Google Play 中该应用的页面.

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?

推荐答案

你可以使用com.android.vending.INSTALL_REFERRER.

Google Play com.android.vending.INSTALL_REFERRER Intent 是从 Google Play 商店安装应用时广播.

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

将此接收器添加到 AndroidManifest.xml

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>

创建一个广播接收器:

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 - 是否有可能以编程方式安装引荐来源网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)