2

I have gone through this link to implement Custom broadcast receiver for measuring campaign data(I used code from same broadcast receiver).

When I tried to use the test scenario from Google using following command in the command prompt, I see a log which says intent is broadcasted with extras. But My broadcast receiver doesn't get called.

adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n com.mypackage/com.google.android.gms.analytics.CampaignTrackingReceiver --es "referrer" "utm_source=testsource"

My manifest code:

 <service android:name="com.google.analytics.tracking.android.CampaignTrackingService" />

        <receiver
            android:name="com.mypackage.CampaignBroadCastReceiver"
            android:exported="true" >
            <intent-filter android:priority="2147483647" >
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>

My broadcast receiver class:

public class CampaignBroadCastReceiver extends BroadcastReceiver {


    @Override
    public void onReceive(Context context, Intent intent) {
        Bundle b=intent.getExtras();

        new CampaignTrackingReceiver().onReceive(context, intent);
    }
}
Community
  • 1
  • 1
Seshu Vinay
  • 13,560
  • 9
  • 60
  • 109

1 Answers1

1

It's working fine now. There is no problem with the code. I gave wrong broadcast receiver in adb shell command and it was broadcasting intent to different receiver.

Seshu Vinay
  • 13,560
  • 9
  • 60
  • 109
  • 1
    Hey, thank you! Saved my live. One thing to add: Maybe you should write the correct command, like this: adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n com.mypackage/your.receiver.package.name.CampaignBroadCastReceiver --es "referrer" "utm_source=testsource" – Paul Weber Aug 19 '15 at 12:23
  • @AbhinavGupta Same code from the question. And ADB comaand is: adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n com.mypackage/your.receiver.package.name.CampaignBroadCastReceiver --es "referrer" "utm_source=testsource" – Seshu Vinay Oct 09 '18 at 11:04
  • can you help i am new in android I want to one thing in google analytics can you give answer of this question : https://stackoverflow.com/q/52715980/7319704 – Abhinav Gupta Oct 09 '18 at 11:09