For AI agents: the complete documentation index is available at /apps-plugin/docs/llms.txt, the full documentation bundle is available at /apps-plugin/docs/llms-full.txt, and this page is available as Markdown at /apps-plugin/docs/js-api/device/battery/onBatteryInfoChange.md.

onBatteryInfoChange

监听电池信息变化事件。

扫码预览

扫码预览 onBatteryInfoChange

支持版本

前端库版本不低于 0.0.25。

支持平台

平台支持情况
Android支持
iOS支持
PC不支持
HarmonyOS不支持

支持场景

场景支持情况
页面支持
卡片不支持

使用说明

  • 取消函数只移除本地回调,不影响系统省电模式状态

调用方式

事件监听 API

onBatteryInfoChange(callback: (event: BatteryInfoChangeEvent) => void): () => void

入参

无。

调用示例

import { onBatteryInfoChange } from '@doubao-dev/framework/api';

const off = onBatteryInfoChange(({ isLowPowerModeEnabled }) => {
  console.log(isLowPowerModeEnabled);
});

off();

回调参数

名称类型必返说明
event.isLowPowerModeEnabledboolean是是否处于省电模式。

返回值

返回取消当前监听函数的函数。

回调示例

{
  "isLowPowerModeEnabled": true
}