@Override protected void onResume() { super.onResume(); sharedPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener); recordingTrackId = PreferencesUtils.getLong(this, R.string.recording_track_id_key); updateUi(); }
@SuppressWarnings("deprecation") @Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); addPreferencesFromResource(R.xml.backup_reset_settings); sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE); backupPreference = findPreference(getString(R.string.settings_backup_key)); backupPreference.setOnPreferenceClickListener( new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Intent intent = IntentUtils.newIntent(BackupResetSettingsActivity.this, BackupActivity.class); startActivity(intent); return true; } }); restoreNowPreference = findPreference(getString(R.string.settings_restore_key)); restoreNowPreference.setOnPreferenceClickListener( new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { showDialog(DIALOG_CONFIRM_RESTORE_ID); return true; } }); resetPreference = findPreference(getString(R.string.settings_reset_key)); resetPreference.setOnPreferenceClickListener( new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { showDialog(DIALOG_CONFIRM_RESET_ID); return true; } }); }
@Override protected void onPause() { super.onPause(); sharedPreferences.unregisterOnSharedPreferenceChangeListener(sharedPreferenceChangeListener); }