コード例 #1
0
ファイル: DatLog.java プロジェクト: JohannaMaisel/DataMonitor
  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);
    }
  }
コード例 #2
0
ファイル: DatLog.java プロジェクト: JohannaMaisel/DataMonitor
  @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();
  }