查询健康类数据
示例代码1:体重为例
int timeout = 0;long endTime = System.currentTimeMillis();long startTime = endTime - 86400000L * 30;HiHealthDataQuery hiHealthDataQuery = new HiHealthDataQuery(HiHealthSetType.DATA_SET_WEIGHT_EX, startTime, endTime, new HiHealthDataQueryOption());HiHealthDataStore.execQuery(context, hiHealthDataQuery, timeout, new ResultCallback() { @Override public void onResult(int resultCode, final Object data) { if (resultCode == HiHealthError.SUCCESS && data instanceof List) { Log.i(TAG, "query not null,enter set data"); List dataList = (List) data; for (Object obj : dataList) { HiHealthSetData hiHealthData = (HiHealthSetData) obj; Log.i(TAG, "data start time : " + hiHealthData.getStartTime()); Log.i(TAG, "data end time : " + hiHealthData.getEndTime()); Map map = hiHealthData.getMap(); Log.i(TAG, "weight : weight " + map.get(HiHealthPointType.DATA_POINT_WEIGHT)); Log.i(TAG, "weight : bmi " + map.get(HiHealthPointType.DATA_POINT_WEIGHT_BMI)); Log.i(TAG, "weight : muscle volume " + map.get(HiHealthPointType.DATA_POINT_WEIGHT_MUSCLES)); Log.i(TAG, "weight : basic metabolism " + map.get(HiHealthPointType.DATA_POINT_WEIGHT_BMR)); Log.i(TAG, "weight : moisture " + map.get(HiHealthPointType.DATA_POINT_WEIGHT_MOISTURE)); Log.i(TAG, "weight : visceral fat " + map.get(HiHealthPointType.DATA_POINT_WEIGHT_FATLEVEL)); Log.i(TAG, "weight : bone mineral content " + map.get(HiHealthPointType.DATA_POINT_WEIGHT_BONE_MINERAL)); Log.i(TAG, "weight : protein " + map.get(HiHealthPointType.DATA_POINT_WEIGHT_PROTEIN)); Log.i(TAG, "weight : body score " + map.get(HiHealthPointType.DATA_POINT_WEIGHT_BODYSCORE)); Log.i(TAG, "weight : physical age " + map.get(HiHealthPointType.DATA_POINT_WEIGHT_BODYAGE)); Log.i(TAG, "weight : body fat percentage " + map.get(HiHealthPointType.DATA_POINT_WEIGHT_BODYFAT)); Log.i(TAG, "weight : body fat scale " + map.get(HiHealthPointType.DATA_POINT_WEIGHT_IMPEDANCE)); Log.i(TAG, "weight : moisture percentage " + map.get(HiHealthPointType.DATA_POINT_WEIGHT_MOISTURERATE)); Log.i(TAG, "weight : skeletal muscle mass " + map.get(HiHealthPointType.DATA_POINT_WEIGHT_SKELETAL_MUSCLE_MASS)); Log.i(TAG, "weight : LHRH impedance " + map.get(HiHealthPointType.DATA_POINT_WEIGHT_LHRHIMPEDANCE)); Log.i(TAG, "weight : LHRHHF impedance " + map.get(HiHealthPointType.DATA_POINT_WEIGHT_LHRHHFIMPEDANCE)); } } else if (resultCode == HiHealthError.PARAM_INVALID) { Log.w(TAG, "Param invalid"); } else if (resultCode == HiHealthError.ERR_HEALTH_VERSION_IS_NOT_SUPPORTED) { Log.w(TAG, "HMS version is too early"); } else if (resultCode == HiHealthError.ERR_HMS_UNAVAILABLE_VERSION) { Log.w(TAG, "HMS version is too early"); } else if (resultCode == HiHealthError.ERR_PERMISSION_EXCEPTION) { Log.w(TAG, "Permission denied"); } else if (resultCode == HiHealthError.ERR_PRIVACY_USER_DENIED) { Log.w(TAG, "Privacy user denied"); } else if (resultCode == HiHealthError.ERR_NETWORK) { Log.w(TAG, "Network request failed"); } else if (resultCode == HiHealthError.ERR_BETA_SCOPE_EXCEPTION) { Log.w(TAG, "Beta scope permission denied"); } else { Log.w(TAG, "Other error, invoking method failed"); } }});
示例代码2:体温为例
int timeout = 0;long endTime = System.currentTimeMillis();long startTime = endTime - 1000 * 60 * 60 * 24 * 30L;HiHealthDataQuery hiHealthDataQuery = new HiHealthDataQuery(HiHealthPointType.DATA_POINT_NEW_BODY_THERMOMETER, startTime, endTime, new HiHealthDataQueryOption());HiHealthDataStore.execQuery(context, hiHealthDataQuery, timeout, new ResultCallback() { @Override public void onResult(int resultCode, Object data) { if (resultCode == HiHealthError.SUCCESS && data instanceof List) { List dataList = (List) data; for (Object obj : dataList) { HiHealthPointData pointData = (HiHealthPointData) obj; Log.i(TAG, "start time : " + pointData.getStartTime()); Log.i(TAG, "body thermometer :" + pointData.getDoubleValue()); } } else if (resultCode == HiHealthError.PARAM_INVALID) { Log.w(TAG, "Param invalid"); } else if (resultCode == HiHealthError.ERR_HEALTH_VERSION_IS_NOT_SUPPORTED) { Log.w(TAG, "Health application need to be updated"); } else if (resultCode == HiHealthError.ERR_HMS_UNAVAILABLE_VERSION) { Log.w(TAG, "HMS version is too early"); } else if (resultCode == HiHealthError.ERR_PERMISSION_EXCEPTION) { Log.w(TAG, "Permission denied"); } else if (resultCode == HiHealthError.ERR_PRIVACY_USER_DENIED) { Log.w(TAG, "Privacy user denied"); } else if (resultCode == HiHealthError.ERR_NETWORK) { Log.w(TAG, "Network request failed"); } else if (resultCode == HiHealthError.ERR_BETA_SCOPE_EXCEPTION) { Log.w(TAG, "Beta scope permission denied"); } else { Log.w(TAG, "Other error, invoking method failed"); } }}); 表2 请求参数
参数名称
参数类型
参数描述
可选选项
query
HiHealthDataQuery
查询条件
必选(M)
timeout
int
超时时间(预留字段,目前没用)
必选(M)
callback
ResultCallback
结果回调
必选(M)
表3 响应参数参数名称
参数类型
参数描述
resultCode
int
处理结果码
0:成功 其他:参见错误码data
Object
数据列表
成功(有数据):List<HiHealthPointData>、List<HiHealthSetData>或List<HiHealthSessionData> 成功(无数据):空列表List<>(0) 其他:错误信息描述(String)示例代码3:科学睡眠详情为例
int timeout = 0;long endTime = System.currentTimeMillis();long startTime = endTime - 1000 * 60 * 60 * 24 * 30L;HiHealthDataQuery hiHealthDataQuery = new HiHealthDataQuery(HiHealthSessionType.DATA_SESSION_CORE_SLEEP, startTime, endTime, new HiHealthDataQueryOption());HiHealthDataStore.execQuery(context, hiHealthDataQuery, timeout, new ResultCallback() { @Override public void onResult(int resultCode, Object data) { if (resultCode == HiHealthError.SUCCESS && data instanceof List) { List dataList = (List) data; for (Object obj : dataList) { HiHealthSessionData sessionData = (HiHealthSessionData) obj; Log.i(TAG, "start time : " + sessionData.getStartTime()); Log.i(TAG, "end time :" + sessionData.getEndTime()); Log.i(TAG, "type :" + sessionData.getType()); } } else if (resultCode == HiHealthError.PARAM_INVALID) { Log.w(TAG, "Param invalid"); } else if (resultCode == HiHealthError.ERR_HEALTH_VERSION_IS_NOT_SUPPORTED) { Log.w(TAG, "Health application need to be updated"); } else if (resultCode == HiHealthError.ERR_HMS_UNAVAILABLE_VERSION) { Log.w(TAG, "HMS version is too early"); } else if (resultCode == HiHealthError.ERR_PERMISSION_EXCEPTION) { Log.w(TAG, "Permission denied"); } else if (resultCode == HiHealthError.ERR_PRIVACY_USER_DENIED) { Log.w(TAG, "Privacy user denied"); } else if (resultCode == HiHealthError.ERR_NETWORK) { Log.w(TAG, "Network request failed"); } else if (resultCode == HiHealthError.ERR_BETA_SCOPE_EXCEPTION) { Log.w(TAG, "Beta scope permission denied"); } else { Log.w(TAG, "Other error, invoking method failed"); } }}); 表4 请求参数
参数名称
参数类型
参数描述
可选选项
query
HiHealthDataQuery
查询条件
必选(M)
timeout
int
超时时间(预留字段,目前没用)
必选(M)
callback
ResultCallback
结果回调
必选(M)
表5 响应参数参数名称
参数类型
参数描述
resultCode
int
处理结果码
0:成功 其他:参见错误码data
Object
数据列表
成功(有数据):List<HiHealthPointData>、List<HiHealthSetData>或List<HiHealthSessionData> 成功(无数据):空列表List<>(0) 其他:错误信息描述(String)相关知识
咨询国家全民健身调查数据统计
医疗健康大数据分类分析.docx
iOS 健康 数据数据库分析
健康大数据
健康大数据 数据大健康
健康大数据研究中心
健康医疗大数据平台
数据精华
医疗健康大数据分析.pptx
健康大数据的分析应用.pptx
网址: 查询健康类数据 https://www.trfsz.com/newsview298354.html
推荐资讯
- 1从出汗看健康 出汗透露你的健 3985
- 2早上怎么喝水最健康? 3760
- 3习惯造就健康 影响健康的习惯 3394
- 4五大原因危害女性健康 如何保 3301
- 5连花清瘟、布洛芬等多款感冒药 3016
- 6补肾吃什么 补肾最佳食物推荐 2592
- 7男子喝水喉咙里像放了刀子一样 2519
- 810人混检核酸几天出结果?1 2278
- 9第二轮新冠疫情要来了?疾控中 2268
- 10转阴多久没有传染性?满足四个 2215