Cannot have more than one INSTALL_REFFERER receiver in Android Manifest
I am using the AdMob install receiver in my Android Manifest file, e.g.
<!-- AdMob Install Receiver -->
开发者_开发百科 <receiver android:name="com.admob.android.ads.analytics.InstallReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
However, I also wish to use my own INSTALL_REFFERER receiver. The problem is, when I include my own receiver after the AdMob one, it never gets called. If I include mine before the AdMob receiver in the manifest file, mine gets called but the AdMob one doesn't.
Is there anyway I can get both to be called?
Thanks
Android app cannot have multiple receivers which have the same intent-filtered action.
Make the proxy receiver like this:
in AndroidManifest.xml:
<receiver android:name="com.example.app.TrackingReceiver" android: exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
in TrackingReceiver.java:
public class TrackingReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// call AdMob tracker
com.google.ads.InstallReceiver ir = new com.google.ads.InstallReceiver();
ir.onReceive(context, intent);
// call Analytics tracker
com.google.android.apps.analytics.AnalyticsReceiver ar = new com.google.android.apps.analytics.AnalyticsReceiver();
ar.onReceive(context, intent);
}
}
精彩评论