As described here, I am subclassing PreferenceFragment and displaying it inside an Activity. That document explains how to listen for preference changes here, but only if yo
You just need to delare the specified Prefernce class in your onResume() method. In my case I was using SwitchPreference class, therefore the code would be like- SettingsActivity.class
public static class PrivacyPreferenceFragment extends PreferenceFragment
{
public SwitchPreference switchPreference;
@Override
public void onResume() {
super.onResume();
switchPreference = (SwitchPreference) findPreference("privacy_notice_check");
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_privacy);
setHasOptionsMenu(true);
}
Then in the activity where you want to use the PrefernceFragment value, just use the SharedPreference object to call the values and trigger it.