Loop with BatteryChanged

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hi,
I want to execute a loop with event batterychanged. In particular I create this code:

Sub PE_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
Dim l As Int

l = Level
If l = Level
While l < 10 Do
Msgbox ("Inserire alimentazione", "Batteria scarica")
Loop
End Sub

but the value of level doesn't change. How can I get the new value of level, if I charge the battery?:(
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
This event is raised every time that the batter level changes. It will be raised automatically.

Hi Erel,
I use this code, to force the user to attach the power cord because the battery is running low.
But when I insert the power cord, the program stops on the loop, because the value of level doesn't change. So, how I can change the code?
 
Upvote 0

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
You should remove this loop. This loop cannot work correctly. The value of L will never change.

You're right, but I want that the msgbox appears continuously, until the user, connect the power cord. :sign0161:
 
Upvote 0

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
It is possible to use a Msgbox. However in this case it will be much simpler to show a Panel over the whole screen. Remove the panel once the charger is connected.

But I don't know when the charger is connected. :(
 
Upvote 0

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Calling it yourself will not help. Assuming that you are using PhoneEvents correctly then it should raise shortly after the charger is connected.

I noticed that the msgbox appear continuously every 25 seconds. Is there a way, to set up the timer to 40 seconds?
 
Upvote 0
Top