ContentValues contentValuesCalorie = new ContentValues();
contentValuesCalorie.put("s_key", "sport_calorie_value");
contentValuesCalorie.put("s_value", value);
- getContentResolver().insert(Uri.parse(SensorDataService.SETTINGS), contentValues);
+ ICLogger.d("sport_calorie_value == > " + value);
+ getContentResolver().insert(Uri.parse(SensorDataService.SETTINGS), contentValuesCalorie);
//获取步数,然后入库
handler.removeCallbacks(this);
handler.postDelayed(this, 1000 * 5);
}
};
-
/**
* 此方法已经是子线程了,不可以再开子线程,包括结果的处理。
* 这样才可以确保单一的一个任务执行,解决并发读取数据不准的问题。
import com.ic.work.SensorDataService;
import com.ic.work.db.PedInjection;
import com.ic.work.db.entity.PedEntity;
+import com.ic.work.utils.ICLogger;
import com.ic.work.utils.PedUtil;
import com.ic.work.utils.SPUtils;
entity.setPedDistance(getDistanceValue(number));
entity.setPedCalorie(getCalorieValue(number));
mPedInjection.updateDBPedDate(entity);
+ //更新卡路里
+ //保存一份到数据库中
+ BigDecimal bg = new BigDecimal(PedUtil.calcConsumeEnergy(mHeight, mWeight, number));
+ String value = String.valueOf(bg.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue());
+ ContentValues contentValuesCalorie = new ContentValues();
+ contentValuesCalorie.put("s_key", "sport_calorie_value");
+ contentValuesCalorie.put("s_value", value);
+ ICLogger.d("sport_calorie_value == > " + value);
+ mContext.getContentResolver().insert(Uri.parse(SensorDataService.SETTINGS), contentValuesCalorie);
}
protected void updateCountDB(int ped, OffsetDateTime dateTime) {