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