文档

设备电量

本文介绍设备电量类WVBattery相关的JS API,供您在通过跨平台DevOps创建H5端应用或者小程序时参考。设备电量类WVBattery相关JS API提供电量获取等能力。

WVBattery.getBatteryInfo

说明

该API只在Windvane Android 1.0.3.4以上版本有效。

获取电量。

输入参数

无输入参数。

回调参数

成功回调参数:

  • [string]level:当前电池电量。

  • [string]isCharging:当前是否在充电状态。

  • [string]chargingType:充电类型, ac代表电源充电,usb代表usb充电,wire代表无线充电。

失败回调参数:

  • [string]msg:错误消息。

window.WindVane.call('WVBattery', 'getBatteryInfo', {}, function(e) {
        alert('success: ' + JSON.stringify(e));
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVBattery.getBatteryInfoSync

说明

该API只在Windvane Android 1.0.3.4以上版本有效

获取电量,同步执行。

输入参数

无输入参数。

回调参数

成功回调参数:

  • [string]level:当前电池电量。

  • [string]isCharging:当前是否在充电状态。

  • [string]chargingType:充电类型, ac代表电源充电,usb代表usb充电,wire代表无线充电。

失败回调参数:

  • [string]msg:错误消息。

window.WindVane.call('WVBattery', 'getBatteryInfoSync', {}, function(e) {
        alert('success: ' + JSON.stringify(e));
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

  • 本页导读 (0)
文档反馈