[英]Google Fit API - How you can read DataType.TYPE_STEP_COUNT_CADENCE from history client
I'm trying to get differents types of data from the History Client of Google fit API.我正在尝试从 Google fit API 的历史客户端获取不同类型的数据。 By now I can read the history of DataType.TYPE_STEP_COUNT_DELTA & DataType.TYPE_DISTANCE_DELTA,现在我可以读取 DataType.TYPE_STEP_COUNT_DELTA 和 DataType.TYPE_DISTANCE_DELTA 的历史记录,
but I can't have any data about the DataType.TYPE_STEP_COUNT_CADENCE, the dataSet of this type never contains any dataPoints.但我无法获得有关 DataType.TYPE_STEP_COUNT_CADENCE 的任何数据,这种类型的数据集从不包含任何数据点。
Can anyone help me on this one?谁能帮我解决这个问题?
Here's how I do:这是我的做法:
Request:要求:
Fitness.getHistoryClient(context, account)
.readData(DataReadRequest.Builder()
.read(DataType.TYPE_STEP_COUNT_CADENCE)
.read(DataType.TYPE_STEP_COUNT_DELTA)
.read(DataType.TYPE_DISTANCE_DELTA)
.setTimeRange(
configuration.startTime.timeInMillis,
configuration.endTime.timeInMillis,
TimeUnit.MILLISECONDS
)
.bucketByTime(1, TimeUnit.HOURS)
.enableServerQueries()
.build()
)
.addOnSuccessListener { response ->
liveDataUpdates.value = PedometerSensorData.fromBuckets(response.buckets)
}
Parsing Data:解析数据:
fun fromBuckets(buckets: List<Bucket>): List<PedometerSensorData> {
...
buckets.forEach { bucket ->
bucket.dataSets.forEach { dataSet ->
if(dataSet.dataType == DataType.TYPE_STEP_COUNT_CADENCE) {
Log.d("TYPE_STEP_COUNT_CADENCE", "STEP COUNT CADENCE IS EMPTY ${dataSet.isEmpty}")
}
...
}
}
The only calculation that Fit ever did to compute cadence was to take points of type DataType.TYPE_STEP_COUNT_DELTA
and divide the value by the duration of the point. Fit 为计算节奏所做的唯一计算是采用DataType.TYPE_STEP_COUNT_DELTA
点并将该值除以该点的持续时间。
So, if you want cadence data, I'd suggest doing that over an appropriate interval.所以,如果你想要节奏数据,我建议在适当的时间间隔内进行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.