Android INSTALL_REFERRER BroadcastReceiver not registering



For the last few days I have been attempting to get a simple INSTALL_REFERRER BroadcastReceiver test to work. But for whatever reason regardless of what I do I can't seem to get my broadcast receiver to register statically via the XML as such:



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://ift.tt/nIICcg"
package="com.packagepath" >

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:name="com.packagepath.CustomApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MyActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

<!-- Used for Google Play Store Campaign Measurement-->;
<receiver android:name=".CustomReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
</manifest>


I'm 100% sure that the package names are correct. However, the only time my application will register a receiver is if I do it manually in my code like so:



protected void onResume() {
super.onResume();
if (cr == null)
cr = new CustomReceiver();
IntentFilter ir = new IntentFilter("com.android.vending.INSTALL_REFERRER");
registerReceiver(cr, ir);

Intent i = new Intent("com.android.vending.INSTALL_REFERRER");
i.setPackage("com.packagepath");
i.putExtra("referrer", "test");
sendBroadcast(i);
}


For reference here is the CustomReceiver's code:



public class CustomReceiver extends BroadcastReceiver {

private static final String D_TAG = "CustomBR";

@Override
public void onReceive(Context context, Intent intent) {
Log.e(D_TAG, "CustomReceiver onReceive (context, intent)");
}
}


I'm also having issues sending broadcast intents to the device via ADB. But once again for whatever reason I cannot get the broadcast to receive my application. I have tried numerous variations of the below examples with now luck. (note: the only thing that is changed is the packagepath)



am broadcast -a com.android.vending.INSTALL_REFERRER -n com.packagepath/.CustomReceiver

am broadcast -a com.android.vending.INSTALL_REFERRER -n com.packagepath/com.packagepath.CustomReceiver --es "referrer" "utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign"

am broadcast -a com.android.vending.INSTALL_REFERRER -n com.packagepath/.CustomReceiver --es "referrer" "utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign"


The absolute only time I actually get the BroadcastReceiver to call is if I both manually register the receiver and manually invoke a broadcast within the application. Can someone please let me know what I'm doing wrong because I've been searching for days now and can't figure it out. Thank you!


No comments:

Post a Comment