All Products
Search
Document Center

SuperApp:Device battery

Last Updated:Jun 23, 2026

The WVBattery JavaScript APIs allow you to retrieve device battery information, such as the battery level and charging status, in HTML5 apps and miniapps.

WVBattery.getBatteryInfo

Note

This API is available only in Windvane for Android 1.0.3.4 or later.

Retrieves the battery level, charging status, and charging type of the device.

Input parameters

None.

Callback parameters

The success callback returns the following parameters:

  • [string] level: The current battery level.

  • [string] isCharging: The charging status of the device.

  • [string] chargingType: The charging type. Valid values are ac for AC charging, usb for USB charging, and wireless for wireless charging.

The failure callback returns the following parameter:

  • [string] msg: The error message.

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

WVBattery.getBatteryInfoSync

Note

This API is available only in Windvane for Android 1.0.3.4 or later.

Synchronously retrieves the battery level, charging status, and charging type of the device.

Input parameters

None.

Callback parameters

The success callback returns the following parameters:

  • [string] level: The current battery level.

  • [string] isCharging: The charging status of the device.

  • [string] chargingType: The charging type. Valid values are ac for AC charging, usb for USB charging, and wireless for wireless charging.

The failure callback returns the following parameter:

  • [string] msg: The error message.

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