获取步数需要先在Health Service Kit联盟卡片中申请日常活动采样数据权限,权限说明见:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/health-permission-description-V5权限申请通过后,在用户授权的前提下,可以通过以下接口获取步数数据:1)可以通过healthStore.readData接口获取步数明细数据;readData:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/health-api-healthstore-V5\#section1934119281922182)可以通过healthStore.aggregateData接口获取步数统计数据;aggregateData:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/health-api-healthstore-V5\#section48781421842163)可以通过workout.readActivityReport读取实时三环数据接口,查询实时的步数数据;readActivityReport:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/health-api-healthservice-V5\#section9432058162017接口调用示例可以参考此sampleCode:https://gitee.com/harmonyos\_samples/health\_-service\_-kit\_-sample-code/tree/master
获取步数需要先在Health Service Kit联盟卡片中申请日常活动采样数据权限,权限说明见:
https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/health-permission-description-V5
权限申请通过后,在用户授权的前提下,可以通过以下接口获取步数数据:
1)可以通过healthStore.readData接口获取步数明细数据;
readData:
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/health-api-healthstore-V5\#section193411928192218
2)可以通过healthStore.aggregateData接口获取步数统计数据;
aggregateData:
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/health-api-healthstore-V5\#section4878142184216
3)可以通过workout.readActivityReport读取实时三环数据接口,查询实时的步数数据;
readActivityReport:
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/health-api-healthservice-V5\#section9432058162017
接口调用示例可以参考此sampleCode:
https://gitee.com/harmonyos\_samples/health\_-service\_-kit\_-sample-code/tree/master