Пример #1
0
  @Override
  protected void onDestroy() {
    CSensorStates lSenStates = mSenStates;
    CLocProvStates lLPStates = mLPStates;

    // Write the preferences
    SharedPreferences lPrefs = getSharedPreferences("DatLogPrefs", MODE_PRIVATE);
    SharedPreferences.Editor lPrefEd = lPrefs.edit();

    // Gps prefs
    for (int i = 0; i < lLPStates.getNum(); i++) {
      lPrefEd.putBoolean(lLPStates.getName(i), lLPStates.getActive(i));
      lPrefEd.putFloat(lLPStates.getName(i) + "_mindist", lLPStates.getMinDist(i));
      lPrefEd.putLong(lLPStates.getName(i) + "_mintime", lLPStates.getMinTime(i));
    }
    lPrefEd.putBoolean("gps_status", mGPSState);

    // Sensor prefs
    for (int i = 0; i < lSenStates.getNum(); i++) {
      lPrefEd.putBoolean(lSenStates.getName(i), lSenStates.getActive(i));
      lPrefEd.putInt(lSenStates.getName(i) + "_rate", lSenStates.getRate(i));
    }

    lPrefEd.commit();

    super.onDestroy();
  }
Пример #2
0
  private void read_prefs() {
    SharedPreferences lPrefs = getSharedPreferences("DatLogPrefs", MODE_PRIVATE);
    CLocProvStates lLPStates = mLPStates;
    CSensorStates lSenNames = mSenStates;
    float mindist;
    long mintime;
    boolean val;
    int rate;

    // Read the sensor preferences
    for (int i = 0; i < lSenNames.getNum(); i++) {
      val = lPrefs.getBoolean(lSenNames.getName(i), false);
      lSenNames.setActive(i, val);
      rate = lPrefs.getInt(lSenNames.getName(i) + "_rate", SensorManager.SENSOR_DELAY_FASTEST);
      lSenNames.setRate(i, rate);
    }

    // Read the location provider preferences
    for (int i = 0; i < lLPStates.getNum(); i++) {
      val = lPrefs.getBoolean(lLPStates.getName(i), false);
      lLPStates.setActive(i, val);
      mindist = lPrefs.getFloat(lLPStates.getName(i) + "_mindist", 0);
      mintime = lPrefs.getLong(lLPStates.getName(i) + "_mintime", 0);
      lLPStates.setCriterion(i, mindist, mintime);
    }

    // Read the GPS Status preference
    val = lPrefs.getBoolean("gps_status", false);
  }
Пример #3
0
  private void register_listeners() {

    CSensorStates lSenStates = mSenStates;
    CLocProvStates lLPStates = mLPStates;
    DataOutputStream[] lfout = fout;
    SensorManager lSenMan = mSenMan;
    LocationManager lLocMan = mLocMan;

    // Register the sensors
    if (lfout[0] != null) {
      for (int i = 0; i < lSenStates.getNum(); i++) {
        if (lSenStates.getActive(i))
          lSenMan.registerListener(
              this, lSenMan.getDefaultSensor(lSenStates.getType(i)), lSenStates.getRate(i));
      }
    }

    // Register listeners for active location providers
    if (lfout[1] != null) {
      for (int i = 0; i < lLPStates.getNum(); i++) {
        if (lLPStates.getActive(i))
          lLocMan.requestLocationUpdates(
              lLPStates.getName(i), lLPStates.getMinTime(i), lLPStates.getMinDist(i), this);
      }
    }

    if (lfout[2] != null) {
      lLocMan.addGpsStatusListener(this);
    }
  }
Пример #4
0
  private void show_registered() {
    CSensorStates lSenStates = mSenStates;
    CLocProvStates lLPStates = mLPStates;

    String nt = "Registered Sources:";
    int n = 0;
    for (int i = 0; i < lSenStates.getNum(); i++) {
      if (lSenStates.getActive(i)) {
        nt = nt + "\n\t" + lSenStates.getName(i);
        n++;
      }
    }

    for (int i = 0; i < lLPStates.getNum(); i++) {
      if (lLPStates.getActive(i)) {
        nt = nt + "\n\t" + lLPStates.getName(i);
        n++;
      }
    }

    if (mGPSState) {
      nt = nt + "\n\tGPS Status";
      n++;
    }

    if (n == 0) {
      nt = "No Registered Source.";
    }

    mLV.addtext(nt);
  }