@Test public void onReceiveWithReferrerAndXtor() { Intent intent = new Intent(); intent.setAction("com.android.vending.INSTALL_REFERRER"); intent.putExtra("referrer", "test=value&xtor=campaign"); referrerReceiver.onReceive(ApplicationProvider.getApplicationContext(), intent); assertEquals("test=value%26xtor=campaign", preferences.getString(TrackerConfigurationKeys.REFERRER, null)); assertEquals("campaign", preferences.getString(TrackerConfigurationKeys.MARKETING_CAMPAIGN_SAVED, null)); }
@Override public void onReceive(android.content.Context context, Intent intent) { if (intent == null) { return; } String action = intent.getAction(); if (action == null || !action.equals(REFERRER_INTENT_ACTION)) { return; } String referrer = intent.getStringExtra(REFERRER); if (referrer == null) { return; } context.getSharedPreferences(TrackerConfigurationKeys.PREFERENCES, android.content.Context.MODE_PRIVATE) .edit().putString(TrackerConfigurationKeys.REFERRER, referrer.replace("&", "%26")) .apply(); referrer = Tool.percentDecode(referrer); String[] campaignParams = referrer.split("&"); for (String param : campaignParams) { String[] paramComponents = param.split("="); String key = paramComponents[0]; if (key.equals(Hit.HitParam.RemanentSource.stringValue())) { context.getSharedPreferences(TrackerConfigurationKeys.PREFERENCES, android.content.Context.MODE_PRIVATE) .edit().putString(TrackerConfigurationKeys.MARKETING_CAMPAIGN_SAVED, paramComponents[1]) .putLong(TrackerConfigurationKeys.LAST_MARKETING_CAMPAIGN_TIME, System.currentTimeMillis()) .apply(); } } }
ReferrerReceiver extends BroadcastReceiver { @Override public void onReceive(android.content.Context context, Intent intent) { if (intent == null) { return; } String action = intent.getAction(); if (action == null || !action.equals(REFERRER_INTENT_ACTION)) { return; } String referrer = intent.getStringExtra(REFERRER); if (referrer == null) { return; } context.getSharedPreferences(TrackerConfigurationKeys.PREFERENCES, android.content.Context.MODE_PRIVATE) .edit().putString(TrackerConfigurationKeys.REFERRER, referrer.replace("&", "%26")) .apply(); referrer = Tool.percentDecode(referrer); String[] campaignParams = referrer.split("&"); for (String param : campaignParams) { String[] paramComponents = param.split("="); String key = paramComponents[0]; if (key.equals(Hit.HitParam.RemanentSource.stringValue())) { context.getSharedPreferences(TrackerConfigurationKeys.PREFERENCES, android.content.Context.MODE_PRIVATE) .edit().putString(TrackerConfigurationKeys.MARKETING_CAMPAIGN_SAVED, paramComponents[1]) .putLong(TrackerConfigurationKeys.LAST_MARKETING_CAMPAIGN_TIME, System.currentTimeMillis()) .apply(); } } } }
ReferrerReceiver extends BroadcastReceiver { @Override public void onReceive(android.content.Context context, Intent intent) { if (intent == null) { return; } String action = intent.getAction(); if (action == null || !action.equals(REFERRER_INTENT_ACTION)) { return; } String referrer = intent.getStringExtra(REFERRER); if (referrer == null) { return; } context.getSharedPreferences(TrackerConfigurationKeys.PREFERENCES, android.content.Context.MODE_PRIVATE) .edit().putString(TrackerConfigurationKeys.REFERRER, referrer.replace("&", "%26")) .apply(); referrer = Tool.percentDecode(referrer); String[] campaignParams = referrer.split("&"); for (String param : campaignParams) { String[] paramComponents = param.split("="); String key = paramComponents[0]; if (key.equals(Hit.HitParam.RemanentSource.stringValue())) { context.getSharedPreferences(TrackerConfigurationKeys.PREFERENCES, android.content.Context.MODE_PRIVATE) .edit().putString(TrackerConfigurationKeys.MARKETING_CAMPAIGN_SAVED, paramComponents[1]) .putLong(TrackerConfigurationKeys.LAST_MARKETING_CAMPAIGN_TIME, System.currentTimeMillis()) .apply(); } } }  }
ReferrerReceiver extends BroadcastReceiver { @Override public void onReceive(android.content.Context context, Intent intent) { if (intent == null) { return; } String action = intent.getAction(); if (action == null || !action.equals(REFERRER_INTENT_ACTION)) { return; } String referrer = intent.getStringExtra(REFERRER); if (referrer == null) { return; } context.getSharedPreferences(TrackerConfigurationKeys.PREFERENCES, android.content.Context.MODE_PRIVATE) .edit().putString(TrackerConfigurationKeys.REFERRER, referrer.replace("&", "%26")) .apply(); referrer = Tool.percentDecode(referrer); String[] campaignParams = referrer.split("&"); for (String param : campaignParams) { String[] paramComponents = param.split("="); String key = paramComponents[0]; if (key.equals(Hit.HitParam.RemanentSource.stringValue())) { context.getSharedPreferences(TrackerConfigurationKeys.PREFERENCES, android.content.Context.MODE_PRIVATE) .edit().putString(TrackerConfigurationKeys.MARKETING_CAMPAIGN_SAVED, paramComponents[1]) .putLong(TrackerConfigurationKeys.LAST_MARKETING_CAMPAIGN_TIME, System.currentTimeMillis()) .apply(); } } }  @Override void onReceive(android.content.Context context, Intent intent); }
ReferrerReceiver extends BroadcastReceiver { @Override public void onReceive(android.content.Context context, Intent intent) { if (intent == null) { return; } String action = intent.getAction(); if (action == null || !action.equals(REFERRER_INTENT_ACTION)) { return; } String referrer = intent.getStringExtra(REFERRER); if (referrer == null) { return; } context.getSharedPreferences(TrackerConfigurationKeys.PREFERENCES, android.content.Context.MODE_PRIVATE) .edit().putString(TrackerConfigurationKeys.REFERRER, referrer.replace("&", "%26")) .apply(); referrer = Tool.percentDecode(referrer); String[] campaignParams = referrer.split("&"); for (String param : campaignParams) { String[] paramComponents = param.split("="); String key = paramComponents[0]; if (key.equals(Hit.HitParam.RemanentSource.stringValue())) { context.getSharedPreferences(TrackerConfigurationKeys.PREFERENCES, android.content.Context.MODE_PRIVATE) .edit().putString(TrackerConfigurationKeys.MARKETING_CAMPAIGN_SAVED, paramComponents[1]) .putLong(TrackerConfigurationKeys.LAST_MARKETING_CAMPAIGN_TIME, System.currentTimeMillis()) .apply(); } } }  @Override void onReceive(android.content.Context context, Intent intent);  }