How can I use multiple install trackers with the Android library?

When your application is installed on a user's handset, the Google Play Store will only deliver referrer information to a single receiver. If Mixpanel is the only library or service you're using to track installs, it's usually enough to simply add the following to your AndroidManifest.xml:

<receiver
  android:name="com.mixpanel.android.mpmetrics.InstallReferrerReceiver"
  android:exported="true">
  <intent-filter>
    <action
     android:name="com.android.vending.INSTALL_REFERRER" />
  </intent-filter>
</receiver>

However, if you want to do your own processing of the install referrer information, or pass the install referrer information on to other third party libraries, you can't just add more receivers to your manifest. This is a known issue with multiple install trackers, but there is a good workaround - you can call all of your trackers individually using your own "parent" tracker. You'll want to include a class like this in your application:

public class ManyInstallTrackersReceiver extends BroadcastReceiver {
  @Override
   public void onReceive(Context context, Intent intent) {
     InstallReferrerReceiver mixpanelReferrerTracking = new InstallReferrerReceiver();
     mixpanelReferrerTracking.onReceive(context, intent);
     // Now you can pass the same intent on to other services,
     // or process it yourself
   }
}

Then, in your AndroidManifest.xml, you can refer to this class instead of Mixpanel:

<receiver
  android:name="my_great_package.ManyInstallTrackersReceiver"
  android:exported="true">
  <intent-filter>
    <action
     android:name="com.android.vending.INSTALL_REFERRER" />
  </intent-filter>
</receiver>