问题描述
Google 文档提到了专门编写血压数据:https://developers.google.com/fit/scenarios/write-bp-data
Google documentation mentions about specifically writing Blood Pressure data: https://developers.google.com/fit/scenarios/write-bp-data
但它没有提到用于 REST API 读取血压数据的 URL?是不是无法通过 REST API 访问健康数据(血压、血糖...),它仅限于健身数据(卡路里、步数、距离...)
But it does not mention URL to be used for REST API to read Blood Pressure data?Is that Health data (Blood Pressure, Blood Glucose...) is not accessible via REST API and it is only limited to Fitness data (Calories, Steps, Distance...)
我希望 REST API 可用于读取血压,以便我可以在 OAuth Playground 中试用它的工作原理.
I was hopeful that REST API would be available for reading Blood Pressure so that I can try it out in OAuth Playground on how it works.
推荐答案
我知道这是关于 REST,但我在 Android 上遇到了同样的问题,所以我会在这里发布我的解决方案,它可能对某人.
I'm aware that this is about REST, but I faced the same question on Android, so I'll post my solution here, it might be helpful to someone.
您需要像对待从 Google 健身中提取的其他信息(即步数、体重...)一样对待血压.
You need to treat Blood Pressure same as you treat other info you're pulling from Google Fit (i.e Steps, Weight...).
您需要将以下行添加到您的健身构建器中:
You need to add the following line to your fitness builder:
FitnessOptions fitnessOptions = FitnessOptions.builder()
------> .addDataType(HealthDataTypes.AGGREGATE_BLOOD_PRESSURE_SUMMARY, FitnessOptions.ACCESS_READ)
.addDataType(DataType.TYPE_WEIGHT, FitnessOptions.ACCESS_READ)
.addDataType(DataType.TYPE_STEP_COUNT_DELTA, FitnessOptions.ACCESS_READ)
.build();
当你需要查询时,使用下面的 HealthDataType:
And when you need to query it, use the following HealthDataType:
public Task<DataReadResponse> queryBloodPressureData(Activity activity, GoogleSignInAccount account) {
return Fitness.getHistoryClient(activity, account)
.readData(new DataReadRequest.Builder()
.aggregate(HealthDataTypes.TYPE_BLOOD_PRESSURE, HealthDataTypes.AGGREGATE_BLOOD_PRESSURE_SUMMARY)
.bucketByTime(1, TimeUnit.MINUTES)
.setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
.build()
);
}
有关完整详细信息,请查看官方文档.
For full details check the official documentation.
这篇关于是否有用于读取血压数据的 Google Fit REST API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!