Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ilyadoroshin/9b0e7dd96a4a3b1f1fe435ddab72e668 to your computer and use it in GitHub Desktop.

Select an option

Save ilyadoroshin/9b0e7dd96a4a3b1f1fe435ddab72e668 to your computer and use it in GitHub Desktop.
A BroadcastReceiver for handling install referrer market broadcasts
public class InstallReferrerReceiver extends BroadcastReceiver {
private static final String TAG = "InstallReferrerReceiver";
@Override
public void onReceive(Context context, Intent intent) {
AnalyticsTrackerFactory.setApiKey(context.getResources().getString(R.string.flurry_key));
HashMap<String, String> values = new HashMap<String, String>();
try {
if (intent.hasExtra("referrer")) {
String referrers[] = intent.getStringExtra("referrer").split("&");
for (String referrerValue : referrers) {
String keyValue[] = referrerValue.split("=");
values.put(URLDecoder.decode(keyValue[0]), URLDecoder.decode(keyValue[1]));
}
}
} catch (Exception e) {
}
Log.d(TAG, "referrer: " + values);
AnalyticsTrackerFactory.getTracker(context).event("Installed", values);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment