I have implemented PhoneEvents and set up an event handler for the batterychanged event.
However, the event fires about every 10 seconds but the values don't change. It's been running for over 30 minutes and has consistently shown 14%, no change.
Note: it is plugged in but the tablet is apparently discharging as fast as it is charging, so the level isn't changing.
Is it normal for it to fire when no changes in battery have (apparently) occurred?
However, the event fires about every 10 seconds but the values don't change. It's been running for over 30 minutes and has consistently shown 14%, no change.
11:43:31 The battery level is: 14 Scale: 100 Plugged: true
11:43:33 The battery level is: 14 Scale: 100 Plugged: true
11:43:43 The battery level is: 14 Scale: 100 Plugged: true
11:43:44 The battery level is: 14 Scale: 100 Plugged: true
11:43:45 The battery level is: 14 Scale: 100 Plugged: true
11:43:45 The battery level is: 14 Scale: 100 Plugged: true
...
12:11:14 The battery level is: 14 Scale: 100 Plugged: true
B4X:
Sub Process_Globals
End Sub
Sub Globals
Dim PE As PhoneEvents
Dim Phone1 As Phone
Dim Phone2 As PhoneWakeState
End Sub
Sub Activity_Create(FirstTime As Boolean)
PE.Initialize("PhEvents")
Log(DateTime.Time(DateTime.Now) & " Activity Start")
End Sub
Sub Activity_Touch (Action As Int, X As Float, Y As Float)
Log(DateTime.Time(DateTime.Now) & " Screen touched")
ScreenAwake
End Sub
Sub PhEvents_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
Log(DateTime.Time(DateTime.Now) & " The battery level is: " & Level & " Scale: " & Scale & " Plugged: " & Plugged)
End Sub
Sub Activity_Resume
ToastMessageShow("activity resume",True)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
ToastMessageShow("activity pause",True)
End Sub
Sub ScreenAwake
ToastMessageShow("Awake sub called", False)
Phone1.SetScreenBrightness(-1)
Phone2.ReleaseKeepAlive
Phone2.KeepAlive(True)
End Sub
Sub ScreenSleep
ToastMessageShow("Sleep sub called", False)
Phone2.ReleaseKeepAlive
Phone1.SetScreenBrightness(0)
Log("Screen sleep")
End Sub
Note: it is plugged in but the tablet is apparently discharging as fast as it is charging, so the level isn't changing.
Is it normal for it to fire when no changes in battery have (apparently) occurred?