可导入跑步课程,助力科学训练

日期: 2023-05-20 14:00:48|浏览: 229|编号: 15474

友情提醒:信息内容由网友发布,本站并不对内容真实性负责,请自鉴内容真实性。

可导入跑步课程,助力科学训练

Kit为开发者提供了自定义跑步课程导入接口,方便用户在华为运动健康App和华为智能穿戴设备上从生态应用中查看训练计划,开始科学适度的运动训练。

跑道导入能力支持生态应用。 获得用户华为帐号授权后,将跑步课程数据写入华为运动健康App,连接现有华为智能穿戴设备并支持课程导入时,直接推送课程表至设备。 在互联网上,用户可以轻松便捷地进行科学的跑步课程训练,提高运动成绩。

开发者使用跑道导入功能前,请参考申请Kit服务完成以下权限的申请:

导入运行课程对应的Scope权限:

Kit联盟卡应用权限名称:健康管理>计划与任务数据。

具体开发过程如下:

将跑步训练计划导入华为运动健康App并展示。

如需配送设备,可跳转到运动健康APP自定义课程详情页,自动将跑步课程配送至设备(华为智能穿戴设备需支持自定义课程,已绑定运动健康 App。当然)。

注意:当华为运动健康App返回的版本号不低于返回版本号时,可以使用跳转功能。

示例代码

运行训练程序导入示例代码。

请求示例

POST
https://health-api.cloud.huawei.com/healthkit/v1/trainingplan/workouts
Content-Type: application/json
Authorization: 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
        }
    ]
}

示例响应

HTTP/1.1 200 OK
Content-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
}

Jump运动健康App完成跑步课程的自动导入。

参数说明

示例代码

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);

提醒:请联系我时一定说明是从高奢网上看到的!