All I want to call receiver on install of APK and get Referrer of it, I have tried to do this, here is my code of receiver class:
public class InstallReferrerReceiver extends BroadcastReceiver {
String TAG = "InstallReferrerReceiver";
@Override
public void onReceive(Context context, Intent intent) {
String referrer = intent.getStringExtra("referrer");
Log.d(TAG, "refferer" + referrer);
//Use the referrer
}}
And here is the Manifest Class:
<receiver
android:name="com.installtracksdk.InstallReferrerReceiver"
android:exported="true"
android:permission="android.permission.INSTALL_PACKAGES">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
try following code:
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_CHANGED" />
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
in manifest file:
<receiver android:name=".YourReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<data android:scheme="package"/>
</intent-filter>
and in java code :
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
intentFilter.addAction(Intent.ACTION_PACKAGE_INSTALL);
intentFilter.addDataScheme("package");
registerReceiver(br, intentFilter);
this will work 7.1 and below devices .On Android 8.0+, you cannot register for those broadcasts in the manifest.
Check this for more detail: link
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.