BatteryChanged event

JdV

Active Member
Licensed User
Longtime User
Hello

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?

Regards

Joe

P.S. I'm very much a :sign0104:
 
does not fire when I initialize the pe

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
Code:
   ... 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
 
Upvote 0
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 ?
 
Upvote 0
It does nit work from activity create it works from service create when I start the service from the app. ( button click)
 
Upvote 0
Back
Top