How to get referrer URL for apps downloaded from outside the market

时光毁灭记忆、已成空白 提交于 2019-12-08 02:54:09

问题


I've found some solutions to track referrer URL from the market, but my apps aren't in the market.

Is there a way to get the referrer URL for applications downloaded from private sites?


回答1:


To get referrer, you need to register your receiver for that. After installation, a broadcast is fired which you need to catch by following code.

First take a look at Android Native Application Tracking Overview

1. Create a Receiver

public class ReferrerReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {

        Bundle extras = intent.getExtras();
        String referrerString = extras.getString("referrer");

        Log.i("Home", "Referrer is: " + referrerString);
    }
}

2. Register in Manifest file

<receiver android:name="your.package.name.ReferrerReceiver" android:exported="true">
<intent-filter>
    <action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>


来源:https://stackoverflow.com/questions/18571920/how-to-get-referrer-url-for-apps-downloaded-from-outside-the-market

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!