开发者

Cannot have more than one INSTALL_REFFERER receiver in Android Manifest

开发者 https://www.devze.com 2023-02-13 14:01 出处:网络
I am using the AdMob install receiver in my Android Manifest file, e.g. <!-- AdMob Install Receiver -->

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);
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消