-
-
Save ilyadoroshin/9b0e7dd96a4a3b1f1fe435ddab72e668 to your computer and use it in GitHub Desktop.
A BroadcastReceiver for handling install referrer market broadcasts
This file contains hidden or 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) { | |
| 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