Pedometer.java 文件源码

java
阅读 31 收藏 0 点赞 0 评论 0

项目:appinventor-extensions 作者:
/**
 * Saves the pedometer state to shared preferences.
 */
@SimpleFunction(description = "Saves the pedometer state to the phone. Permits " +
  "permits accumulation of steps and distance between invocations of an App that uses " +
  "the pedometer. Different Apps will have their own saved state.")
public void Save() {
  // Store preferences
  SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
  SharedPreferences.Editor editor = settings.edit();
  editor.putFloat("Pedometer.stridelength", strideLength);
  editor.putFloat("Pedometer.distance", totalDistance);
  editor.putInt("Pedometer.prevStepCount", numStepsRaw);
  if (pedometerPaused) {
    editor.putLong("Pedometer.clockTime", prevStopClockTime);
  } else {
    editor.putLong("Pedometer.clockTime", prevStopClockTime +
        (System.currentTimeMillis() - startTime));
  }
  editor.putLong("Pedometer.closeTime", System.currentTimeMillis());
  editor.commit();
  Log.d(TAG, "Pedometer state saved.");
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号