导入运动健康服务功能模块及相关公共模块。
import { healthService } from '@kit.HealthServiceKit';
import { hilog } from '@kit.PerformanceAnalysisKit'; 调用readActivityReport方法读取实时三环数据,并处理返回结果。
try {
const result: healthService.workout.ActivityReport = await healthService.workout.readActivityReport();
hilog.info(0x0000, 'testTag', 'Succeeded in reading ActivityReport');
Object.keys(result).forEach(key => {
hilog.info(0x0000, 'testTag', `the ${key} is ${result[key]}`);
});
} catch (err) {
hilog.error(0x0000, 'testTag', `Failed to read ActivityReport. Code: ${err.code}, message: ${err.message}`);
}