dlt.getBatteryInfo
Introduction
The dlt.getBatteryInfo
function is used to retrieve the current device battery information.
Parameters
Object object
Property | Type | Default | Required | Description |
---|---|---|---|---|
success | function | No | Callback function for a successful call. | |
fail | function | No | Callback function for a failed call. | |
complete | function | No | Callback function for the call's completion (executed for both successful and failed calls). |
object.success Callback Function
Parameters
Object res
Property | Type | Description |
---|---|---|
level | number | Current device battery level |
isCharging | boolean | Whether the device is charging |
The level
property is in the range of 0 to 100.
Sample Code
dlt.getBatteryInfo({
success(res) {
console.log(res.level);
console.log(res.isCharging);
},
});