I need to build an app that sends an SMS message when the phone looses power connection.
Is there a library that helps detect when the phone is unplugged, and triggers an event?
Sub PhoneEvent_BatteryChanged( Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent )
PluggedStatus = Plugged
ChargeLevel = Level
If PluggedStatus = False And ChargeLevel < 50 Then
pws.KeepAlive( False )
pws.KeepAlive( True )
End Sub ' PhoneEvent_BatteryChanged()
Plugged tells you if the phone is charging.
In this example, I run the pws.KeepAlive() function depending on the charge level.
The event gets called when the charging status or charge level changes.