Sub GetBatteryLevel As Float
Dim no As NativeObject
no = no.Initialize("UIDevice").RunMethod("currentDevice", Null)
If no.GetField("batteryMonitoringEnabled").AsBoolean = False Then
no.SetField("batteryMonitoringEnabled", True)
End If
Return no.GetField("batteryLevel").AsNumber
End Sub
It returns the exact value here (0.89 for example). Anyway this is a native method so there is not much that you can do about it.I was hoping for 1% granularity like we get on Android devices with B4A.
'0 = Unknown
'1 = Unplugged
'2 = Charging
'3 = Full
Sub GetBatteryState As Int
Dim no As NativeObject
no = no.Initialize("UIDevice").RunMethod("currentDevice", Null)
If no.GetField("batteryMonitoringEnabled").AsBoolean = False Then
no.SetField("batteryMonitoringEnabled", True)
End If
Return no.GetField("batteryState").AsNumber
End Sub