HarmonyOS 鸿蒙Next计步传感器相关问题咨询
HarmonyOS 鸿蒙Next计步传感器相关问题咨询
我这边想咨询一下api中获取计步的方法,下面这个方法获取的步数是开机以来的总步数还是今日步数?有无相关获取今日步数的api?
import sensor from “@ohos.sensor”;
import BusinessError from “@ohos.base”;
try {
sensor.on(sensor.SensorId.PEDOMETER, (data: sensor.PedometerResponse) => {
console.info('Succeeded in invoking on. Step count: ’ + data.steps);
}, { interval: 100000000 });
setTimeout(() => {
sensor.off(sensor.SensorId.PEDOMETER);
}, 500);
} catch (error) {
let e: BusinessError.BusinessError = error as BusinessError.BusinessError;
console.error(Failed to invoke on. Code: <span class="hljs-subst">${e.code}</span>, message: <span class="hljs-subst">${e.message}</span>
);
}
我这边有个需求是获取今日步数,换算成碳积分的功能
更多关于HarmonyOS 鸿蒙Next计步传感器相关问题咨询的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html