#Region Service Attributes
#StartAtBoot: true
#End Region
Sub Process_Globals
Dim hc As HttpClient
Dim pe As PhoneEvents
Dim last As Int
End Sub
Sub Service_Create
Dim n As Notification
n.Initialize
n.AutoCancel = False
n.OnGoingEvent = True
n.Vibrate = False
n.Sound = False
n.Light = False
n.Icon = "icon"
n.SetInfo("BatMon", "starting", Main)
last = 0
Service.StartForeground(1, n)
hc.InitializeAcceptAll("hc")
pe.Initialize("pe")
End Sub
Sub Service_Start (StartingIntent As Intent)
pe.Initialize("pe")
End Sub
Sub Service_Destroy
Service.StopForeground(1)
Dim n As Notification
n.Initialize
n.Cancel(1)
pe.StopListening
End Sub
Sub pe_BatteryChanged(Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
If last = Level Then
StartServiceAt(Me, DateTime.Now + (DateTime.Ticksperhour * 4), True)
Return
End If
Dim n As Notification
n.Initialize
n.AutoCancel = False
n.OnGoingEvent = True
Dim so As Boolean = False
If Level < 10 Then so = True
n.Vibrate = so
n.Sound = so
n.Light = False
n.Icon = "icon"
n.SetInfo("BatMon", Level & "%", Main)
n.Notify(1)
last = Level
upload(Level)
StartServiceAt(Me, DateTime.Now + (DateTime.TicksPersecond * 4), True)
End Sub
Sub upload(level As Int)
StartServiceAt(Me, DateTime.Now + (DateTime.Ticksperhour * 6), True)
Dim hr As HttpRequest
hr.InitializeGet("http://www.somesite.com/battery.php?lv=" & level & "&id=" & File.ReadString(File.DirInternal, "id.txt"))
hc.Execute(hr, 1)
End Sub
Sub hc_ResponseSuccess (response As HttpResponse, TaskId As Int)
End Sub
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
End Sub