@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ContextManager.setContext(this);
    addPreferencesFromResource(getPreferenceResource());
  }
 @Override
 public void onWindowFocusChanged(boolean hasFocus) {
   super.onWindowFocusChanged(hasFocus);
   if (hasFocus) {
     initializePreference(getPreferenceScreen());
   }
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    result = savedInstanceState == null ? new Bundle() : savedInstanceState.getBundle(EXTRA_RESULT);

    addPreferencesFromResource(R.xml.preferences_reminders);

    if (preJellybean()) {
      getPreferenceScreen()
          .removePreference(findPreference(getString(R.string.p_rmd_notif_actions_enabled)));
    }

    if (deviceInfo.supportsLocationServices()) {
      setExtraOnChange(R.string.p_geofence_radius, RESET_GEOFENCES);
      setExtraOnChange(R.string.p_geofence_responsiveness, RESET_GEOFENCES);
      setExtraOnChange(R.string.p_geofence_reminders_enabled, TOGGLE_GEOFENCES);
    } else {
      getPreferenceScreen()
          .removePreference(findPreference(getString(R.string.geolocation_reminders)));
    }

    initializeRingtonePreference();
    initializeTimePreference(getDefaultRemindTimePreference(), REQUEST_DEFAULT_REMIND);
    initializeTimePreference(getQuietStartPreference(), REQUEST_QUIET_START);
    initializeTimePreference(getQuietEndPreference(), REQUEST_QUIET_END);
  }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode == RESULT_OK) {
     switch (requestCode) {
       case REQUEST_QUIET_START:
         getQuietStartPreference().handleTimePickerActivityIntent(data);
         return;
       case REQUEST_QUIET_END:
         getQuietEndPreference().handleTimePickerActivityIntent(data);
         return;
       case REQUEST_DEFAULT_REMIND:
         getDefaultRemindTimePreference().handleTimePickerActivityIntent(data);
         return;
     }
   }
   super.onActivityResult(requestCode, resultCode, data);
 }
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putBundle(EXTRA_RESULT, result);
 }