Last active
December 31, 2017 21:48
-
-
Save ggrell/1877105 to your computer and use it in GitHub Desktop.
A BroadcastReceiver for handling install referrer market broadcasts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class InstallReferrerReceiver extends BroadcastReceiver { | |
private static final String TAG = "InstallReferrerReceiver"; | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
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); | |
} | |
} |
I think AnalyticsTrackerFactory was some general wrapper around analytics, so I could use any analytics package, or multiple at once.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what @ganesh-gbg said. Came here after googling from this same code on your blog.