HUAWEI Health Kit为开发者提供用户自定义的跑步课程导入接口,便于用户在华为运动健康App和华为智能穿戴设备上查看来自生态应用的训练课表,开启科学、适度的运动训练。
跑步课程导入能力支持生态应用在获取用户的华为帐号授权后,将跑步课程数据写入至华为运动健康App,并在已有的华为智能穿戴设备连接并支持课程导入时,直接将课表推送到设备上,用户可以轻松便捷地投入到科学的跑步课程训练中,提升运动表现。

开发者在使用跑步课程导入功能前,请参见申请Health Kit服务完成以下权限的申请:
跑步课程导入对应的Scope权限:ec9K9s2c8@1M7s2y4Q4x3@1q4Q4x3V1k6Q4x3V1k6%4N6%4N6Q4x3X3g2Z5N6h3q4%4k6h3W2Q4x3X3g2U0L8$3#2Q4x3V1k6Z5k6h3q4D9N6r3S2C8K9i4c8Q4x3V1k6D9L8$3y4S2N6r3W2G2L8W2)9J5k6i4N6J5K9i4c8W2
Health Kit联盟卡片申请的权限名称:健康管理 >计划和任务数据。
具体开发流程如下:
将跑步训练计划导入到华为运动健康App并展示。
若需要进行设备下发,可以通过DeepLink跳转到运动健康App自定义课程的详情页面,并实现跑步课程自动下发到该设备(需要华为智能穿戴设备支持自定义课程,并已与运动健康App绑定)。
说明:当获取华为运动健康App版本号返回的versionCode不低于1300002300 时,可使用DeepLink跳转功能。
跑步训练计划导入示例代码。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | POSThttps://health-api.cloud.huawei.com/healthkit/v1/trainingplan/workoutsContent-Type: application/jsonAuthorization: Bearer ***x-client-id: ***x-version: ***x-caller-trace-id: ***{ "name": "01:乳酸阈值课程", "description": "总距离:7.02公里;总时间:1:19:00;训练负荷:29.7", "actionCombine": [ { "actionList": [ { "name": "Warm up", "describe": "暖身", "target": { "name": "time", "value": 900.0 }, "strength": { "name": "pace", "valueH": 614000.0, "valueL": 614000.0 } } ], "repeatTimes": 1 }, { "actionList": [ { "name": "relax", "describe": "动态伸展", "target": { "name": "time", "value": 300.0 } } ], "repeatTimes": 1 }, { "actionList": [ { "name": "run", "describe": "跑步训练5分钟", "target": { "name": "time", "value": 300.0 }, "strength": { "name": "pace", "valueH": 486000.0, "valueL": 486000.0 } }, { "name": "have a rest", "describe": "缓走或休息", "target": { "name": "time", "value": 60.0 } }, { "name": "relax", "describe": "静态伸展", "target": { "name": "time", "value": 300.0 } } ], "repeatTimes": 9 } ]} |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | HTTP/1.1 200 OKContent-type: application/json;charset=utf-8{ "workoutId": "1669019290232", "name": "01:乳酸阈值课程", "description": "总距离:7.02公里;总时间:1:19:00;训练负荷:29.7", "actionCombine": [ { "repeatTimes": 1, "actionList": [ { "name": "Warm up", "describe": "暖身", "target": { "name": "time", "value": 900.0 }, "strength": { "name": "pace", "valueH": 614000.0, "valueL": 614000.0 } } ] }, { "repeatTimes": 1, "actionList": [ { "name": "relax", "describe": "动态伸展", "target": { "name": "time", "value": 300.0 } } ] }, { "repeatTimes": 9, "actionList": [ { "name": "run", "describe": "跑步训练5分钟", "target": { "name": "time", "value": 300.0 }, "strength": { "name": "pace", "valueH": 486000.0, "valueL": 486000.0 } }, { "name": "have a rest", "describe": "缓走或休息", "target": { "name": "time", "value": 60.0 } }, { "name": "relax", "describe": "静态伸展", "target": { "name": "time", "value": 300.0 } } ] } ], "createTime": 1669019290232} |
DeepLink跳转运动健康App完成跑步课程自动导入。

1 2 3 4 | String deeplink="huaweischeme://healthapp/fitnesspage?skip_type=custom_course&id=workoutId&version=2.0"; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(deeplink));intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);startActivity(intent); |
了解更多详情>>
更多相关内容请参见跑步课程导入章节。
如您需要了解更多功能,请访问华为运动健康服务联盟官网。
关注我们,第一时间了解 HMS Core 最新技术资讯~