my.getBatteryInfoSync

Use this API to synchronously obtain the battery level and the charging state of the current device. No parameters are required.

Return Values

PropertyTypeDescription
levelIntThe battery level of the current device. 
isChargingBooleanThis property indicates whether the device is charging.

Sample Code

copy
var res = my.getBatteryInfoSync();
my.alert({content: 'System information:'+JSON.stringify(res)});
console.log({content: 'System information:'+JSON.stringify(res),});