'Service module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim GPS1 As GPS
Dim count As Int
Dim HC As HttpClient
Dim url As String
Dim hora As String
End Sub
Sub Service_Create
GPS1.Initialize("GPS")
HC.Initialize("HC")
If GPS1.GPSEnabled = False Then
ToastMessageShow("Please enable the GPS device.", True)
StartActivity(GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
End If
End Sub
Sub GPS_LocationChanged (Location1 As Location)
count = count + 1
If Location1.Accuracy <=100 Then
'call sub to send data to server
hora=DateTime.Date(Location1.Time + 6*DateTime.TicksPerHour)
url = "http://XXXX.XX?UnitId="&"XXXX"&"&date="&hora&"&latitude="&Location1.Latitude&"&longitude="&Location1.Longitude&"&speed="&(Location1.Speed*3.6)&"&rawdata=EcuService"
ToastMessageShow(url, True)
Dim req As HttpRequest
req.InitializeGet(url)
HC.Execute(req, 1)
End If
GPS1.Stop
End Sub
Sub HC_ResponseError (Reason As String, StatusCode As Int, TaskId As Int)
ToastMessageShow("Error: " & Reason, True)
End Sub
Sub HC_ResponseSuccess (Response As HttpResponse, TaskId As Int)
ToastMessageShow("success", True)
End Sub
Sub Service_Start (StartingIntent As Intent)
DateTime.DateFormat = "yyyy-MM-dd%20HH:mm:ss"
StartServiceAt("", DateTime.Now + 5 * DateTime.TicksPerMinute, False)
ToastMessageShow("SS Turning GPS ON", True)
GPS1.Start(0, 0) 'Listen to GPS with no filters.
count = 0
End Sub
Sub Service_Destroy
End Sub