I'm trying to log what comes from installing app from store. But my custom receiver does not work when actual installation from Play Market occurs, however it works when I'm using adb to broadcast something like this.
adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n "package_name"/.InstallReceiver --es referrer "TOPKEK"
Broadcasting: Intent { act=com.android.vending.INSTALL_REFERRER cmp="package_name"/.InstallReceiver (has extras) }
Receiver works as expected:
D/InstallReceiver: onReceive() called with: context = [android.app.ReceiverRestrictedContext@2af18590], intent = [Intent { act=com.android.vending.INSTALL_REFERRER flg=0x10 cmp="package_name"/.InstallReceiver (has extras) }extras=[Bundle{referrer='TOPKEK'}]]
But when installing from Google Play App the only thing in log is message from CampaignTrackingReceiver: "CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible. See http://goo.gl/8Rd3yj for instructions."
Code of receiver:
package "package_name";
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.adjust.sdk.AdjustReferrerReceiver;
import "package_name".util.LogHelper;
public final class InstallReceiver extends BroadcastReceiver {
private static final String TAG = "InstallReceiver";
@Override
public void onReceive(final Context context, final Intent intent) {
Log.d(TAG, "onReceive() called with: " + "context = [" + context + "], intent = [" + LogHelper.format(intent) + "]");
new AdjustReferrerReceiver().onReceive(context, intent);
}
}
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="package_name"
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- normal permissions -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<permission
android:name="'package_name'.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="'package_name'.permission.C2D_MESSAGE"/>
<application
android:name=".CustomApplication"
android:allowBackup="true"
android:fullBackupContent="false"
android:icon="@drawable/menu_icon_earny"
android:label="@string/app_name"
android:theme="@style/AppTheme">
//activities here
//gcm stuff
<!-- Google Analytics -->
<receiver android:name="com.google.android.gms.analytics.AnalyticsReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH"/>
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.analytics.AnalyticsService"
android:enabled="true"
android:exported="false"/>
<!--My install receiver that didn't work as intended-->
<receiver
android:name=".InstallReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER"/>
</intent-filter>
</receiver>
</application>
</manifest>
UPD: I need my receiver to work, I need that log not google receiver.