HomeDocs
Skip to main content

dlt.getBatteryInfo

Introduction

The dlt.getBatteryInfo function is used to retrieve the current device battery information.

Parameters

Object object

PropertyTypeDefaultRequiredDescription
successfunctionNoCallback function for a successful call.
failfunctionNoCallback function for a failed call.
completefunctionNoCallback function for the call's completion (executed for both successful and failed calls).

object.success Callback Function

Parameters

Object res

PropertyTypeDescription
levelnumberCurrent device battery level
isChargingbooleanWhether 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);
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.