Source:
<code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.pref_general); <START> addPreferencesFromResource(R.xml.pref_general); <END> bindPreferenceSummaryToValue(findPreference(getString(R.string.font_sizes))); bindPreferenceSummaryToValue(findPreference(getString(R.string.dhis_url))); bindPreferenceSummaryToValue(findPreference(getString(R.string.org_unit))); SettingsActivity settingsActivity = (SettingsActivity) getActivity(); AutoCompleteEditTextPreference autoCompleteEditTextPreference = (AutoCompleteEditTextPreference) findPreference(getString(R.string.org_unit)); autoCompleteEditTextPreference.setOnPreferenceClickListener(new LoginRequiredOnPreferenceClickListener(settingsActivity, true)); settingsActivity.setAutoCompleteEditTextPreference(autoCompleteEditTextPreference); Preference removeSentPreference = (Preference)findPreference(getString(R.string.remove_sent_surveys)); removeSentPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { askRemoveSentSurveys(getActivity()); return true; } }); Preference serverUrlPreference = (Preference)findPreference(getResources().getString(R.string.dhis_url)); serverUrlPreference.setOnPreferenceClickListener(new LoginRequiredOnPreferenceClickListener(settingsActivity, false)); serverUrlPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { PreferencesState.getInstance().saveStringPreference(R.string.dhis_url, newValue.toString()); preference.setSummary(newValue.toString()); PreferencesState.getInstance().reloadPreferences(); ((SettingsActivity) getActivity()).initReloadByServerVersion(newValue.toString()); return true; } }); ((SettingsActivity)getActivity()).initPopulateOrgUnitsByServerVersion(PreferencesState.getInstance().getDhisURL()); }</code><technical_language>@ivanarrizabalaga adding this twice</technical_language>

Target:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.pref_general); bindPreferenceSummaryToValue(findPreference(getString(R.string.font_sizes))); bindPreferenceSummaryToValue(findPreference(getString(R.string.dhis_url))); bindPreferenceSummaryToValue(findPreference(getString(R.string.org_unit))); SettingsActivity settingsActivity = (SettingsActivity) getActivity(); AutoCompleteEditTextPreference autoCompleteEditTextPreference = (AutoCompleteEditTextPreference) findPreference(getString(R.string.org_unit)); autoCompleteEditTextPreference.setOnPreferenceClickListener(new LoginRequiredOnPreferenceClickListener(settingsActivity, true)); settingsActivity.setAutoCompleteEditTextPreference(autoCompleteEditTextPreference); Preference removeSentPreference = (Preference)findPreference(getString(R.string.remove_sent_surveys)); removeSentPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { askRemoveSentSurveys(getActivity()); return true; } }); Preference serverUrlPreference = (Preference)findPreference(getResources().getString(R.string.dhis_url)); serverUrlPreference.setOnPreferenceClickListener(new LoginRequiredOnPreferenceClickListener(settingsActivity, false)); serverUrlPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { PreferencesState.getInstance().saveStringPreference(R.string.dhis_url, newValue.toString()); preference.setSummary(newValue.toString()); PreferencesState.getInstance().reloadPreferences(); ((SettingsActivity) getActivity()).initReloadByServerVersion(newValue.toString()); return true; } }); ((SettingsActivity)getActivity()).initPopulateOrgUnitsByServerVersion(PreferencesState.getInstance().getDhisURL()); }