DeviceData.BatteryLevel

From Xojo Documentation

Read-Only Property (As Double )
DoubleValue = aDeviceData.BatteryLevel

New in 2020r2

Supported for all project types and targets.

The amount of battery remaining.

Notes

A value of 0.0 means the battery is full discharged. A value of 1.0 means the battery is fully charged.

Sample Code

This example enables monitoring of the battery, gets the current battery level, disables battery monitoring and then displays the level in a message box:

System.Device.BatteryMonitoringEnabled = True
Var batteryPercentage As Integer = System.Device.BatteryLevel * 100
System.Device.BatteryMonitoringEnabled = False
MessageBox("Your battery is at " + batteryLevel.ToString + "%")

See Also

BatteryState property.