Is there a way of reading the current state of the battery (i.e. whether it's charging and how much power is left) without the device having to fire the 'BatteryChanged' event first?
You can only get the battery state by handling the BatteryChanged event. However this event is special. It will fire immediately after calling Initialize (or InitializeWithPhoneState).
You can only get the battery state by handling the BatteryChanged event. However this event is special. It will fire immediately after calling Initialize (or InitializeWithPhoneState).
Hi,
is this still true ?
here is my code and nothing happen when I run the app
B4X:
... process global
Dim PE As PhoneEvents
End Sub
Sub PE1_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
Log("BatteryChanged: Level = " & Level & ", Scale = " & Scale & ", Plugged = " & Plugged)
End Sub
Sub Activity_Create(FirstTime As Boolean)
PE.Initialize("PE1")
....
end sub
with the help of NJDude I realize that this code is working when not initialize from the activity create sub, if I put this in a service create sub it will run almost immediately, anyone know why it is not working (not running until the battery level change) from service create ?