Starting from version 1078, the API prefix has been changed from hbs to qg. The original prefix hbs is still supported.
API | Description |
|---|---|
Obtains the device battery level. | |
Obtains the device battery level in synchronous mode. |
Parameter | Type | Mandatory | Description |
|---|---|---|---|
success | function | No | Callback function triggered upon a successful API call. For details, please refer to Parameters in the success callback function. |
fail | function | No | Callback function triggered upon a failed API call. |
complete | function | No | If a function is passed, it will be called regardless of whether the API call succeeds or fails. |
qg.getBatteryInfo({
success : function (res) {
console.log("getBatteryInfo success level = " + res.level);
},
fail:function(){
console.log("getBatteryInfo fail");
},
complete:function() {
console.log("getBatteryInfo complete");
}
}); Parameter | Type | Description |
|---|---|---|
isCharging | boolean | Indicates whether the battery is being charged. |
level | string | Device battery level. The value ranges from 1 to 100. |
const batteryInfo = qg.getBatteryInfoSync(); console.log(batteryInfo.level); console.log(batteryInfo.isCharging);