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
| Property | Type | Description |
| level | Int | The battery level of the current device. |
| isCharging | Boolean | This 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),});