健康服务中的去抖动目标
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
健康服务现在支持针对瞬时指标(例如心率、距离和速度)进行去抖动目标。对于想要在整个锻炼过程中保持特定阈值或范围(例如心率)的用户,去抖动目标可以改善用户体验。
去抖动目标可防止在短时间内多次发出同一事件(每当条件为 true 时)。而是仅在持续超过阈值一段时间(通常为数秒)内持续超出阈值时,才会发出事件。达到阈值的时长是指在健康服务发送提醒事件之前,用户需要超过指定阈值的不间断时长。
您还可以防止事件在目标注册后立即发出。初始延迟时间是指从目标注册到应用收到通知所必须经过的时间。
如果您的应用允许用户设置健身目标或目标值,则“达到阈值的时长”和“初始延迟时间”可减少向用户显示的误报和重复提醒的数量。
案例研究:心率
去抖动目标的一个常见用例涉及心率区间。心率在整个锻炼过程中持续波动,特别是有氧运动强度时。如果不支持去抖动,应用可能会在短时间内收到许多提醒,例如每当用户的心率降到或低于目标范围时。
通过引入“初始延迟”,您可以告知健康服务仅在指定时间段过后才发送目标提醒 - 您可以将其视为调整期。通过引入“达到阈值的时长”,您可以进一步进行自定义,方法是指定用户进入或离开指定阈值时要激活其目标所必须经过的时间。
在实践中,这可能包括等待用户离开目标心率范围 15 秒,然后应用才会通知他们增加或降低锻炼强度。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Debounced goals in Health Services\n\nHealth Services now supports *debounced goals* for instantaneous metrics, such\nas heart rate, distance, and speed. Debounced goals improve the user experience\nfor people who want to maintain a specific threshold or range---such as heart\nrate---throughout their workout.\n\nDebounced goals prevent the same event from being emitted multiple times---every\ntime the condition is true---over a short time period. Instead, events are emitted\nonly if the threshold has been continuously exceeded for a configurable period\nof time, usually some number of seconds. **Duration at threshold** is the amount\nof uninterrupted time the user needs to cross the specified threshold before\nHealth Services sends an alert event.\n\nYou can also prevent events from being emitted immediately after goal\nregistration. **Initial delay** is the amount of time that must pass, since goal\nregistration, before your app is notified.\n\nWhen combined, \"duration at threshold\" and \"initial delay\" reduce the number of\nfalse positives and repeated alerts surfaced to users if your app lets users set\nfitness goals or targets.\n\nCase study: heart rate\n----------------------\n\nA common use case for debounced goals involves heart rate zones. Heart rate\ncontinuously fluctuates throughout an exercise, especially during\ncardio-intensive activities. Without support for debouncing, an app might get\nmany alerts in a short period of time, such as each time the user's heart rate\ndips above or below the target range.\n\nBy introducing an \"initial delay,\" you can inform Health Services to send a goal\nalert only after a specified time period has passed--you can think of this as an\nadjustment period. By introducing a \"duration at threshold,\" you can take this\ncustomization further, by specifying the amount of time that must elapse while\nthe user is in or out of the specified threshold for their goal to be activated.\n\nIn practice, this might involve waiting for the user to be out of their target\nheart rate range for 15 seconds before your app lets them know to increase or\ndecrease their exercise intensity."]]