public void onStop() {
   super.onStop();
   LocationState.removeLocationChangeListener(this);
   A.getGuidingContent().removeGuidingListener(this);
   A.getRotator().removeListener(this);
 }
  @Override
  public boolean onPreferenceChange(final Preference preference, final Object value) {
    boolean status = true;

    if (isPreference(preference, R.string.pref_highlight)) {
      PreferenceFunc.enableWakeLock();
      // TODO preference.setSummary( stringValue );
    } else if (isPreference(preference, R.string.pref_wherigo_engine_deviceid)) {
      OpenWigHelper.SetDeviceId(value.toString());
    } else if (isPreference(preference, R.string.pref_wherigo_engine_platform)) {
      OpenWigHelper.SetPlatform(value.toString());
    } else if (isPreference(preference, R.string.pref_sensors_compass_hardware)) {
      // TODO check if new value already persisted
      A.getRotator().manageSensors();
    } else if (isPreference(preference, R.string.pref_sensors_compass_auto_change)) {
      // TODO check if new value already persisted
      A.getRotator().manageSensors();
    } else if (isPreference(preference, R.string.pref_sensors_compass_auto_change_value)) {
      if (Utils.parseInt(value) <= 0) {
        ManagerNotify.toastShortMessage(R.string.invalid_value);
        status = false;
      }
    } else if (isPreference(preference, R.string.pref_language)) {
      // TODO activity.needRestart = true;
      return true;
    } else if (isPreference(preference, R.string.pref_cartridgelist_sorting)) {
      YaawpAppData.GetInstance().mRefreshCartridgeList = true;
    } else if (isPreference(preference, R.string.pref_cartridgelist_anywhere_first)) {
      YaawpAppData.GetInstance().mRefreshCartridgeList = true;
    } else if (isPreference(preference, R.string.pref_scan_external_storage)) {
      // TODO YaawpAppData.GetInstance().mCartridges.clear(); // TODO set flag for new file scan
    } else if (isPreference(preference, R.string.pref_exclude_android_dir)) {
      // TODO YaawpAppData.GetInstance().mCartridges.clear(); // TODO set flag for new file scan
    } else if (isPreference(preference, R.string.pref_exclude_hidden_dirs)) {
      // TODO YaawpAppData.GetInstance().mCartridges.clear(); // TODO set flag for new file scan
    } else if (isPreference(preference, R.string.pref_exclude_whereyougo_dir)) {
      // TODO YaawpAppData.GetInstance().mCartridges.clear(); // TODO set flag for new file scan
    } else if (isPreference(preference, R.string.pref_include_dropbox_dir)) {
      // TODO YaawpAppData.GetInstance().mCartridges.clear(); // TODO set flag for new file scan
    } else if (isPreference(preference, R.string.pref_guiding_sound_type)) {
      int result = Utils.parseInt(value);
      if (result == PreferenceValues.GuidingWaypointSound.CUSTOM_SOUND) {
        // lastUsedPreference = (ListPreference) pref;
        Intent intent = new Intent(Intent.ACTION_PICK);
        intent.setType("audio/*");
        if (!Utils.isIntentAvailable(intent)) {
          intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
        }
        this.startActivityForResult(intent, REQUEST_GUIDING_WPT_SOUND);
        status = true; // don't set the preference yet
      }
    } else if (isPreference(preference, R.string.pref_guiding_sound_distance)) {
      int distance = Utils.parseInt(value);
      if (distance <= 0) {
        ManagerNotify.toastShortMessage(R.string.invalid_value);
        status = false;
      }
    }

    return status;
  }
 public void onStart() {
   super.onStart();
   LocationState.addLocationChangeListener(this);
   A.getGuidingContent().addGuidingListener(this);
   A.getRotator().addListener(this);
 }