'Activity 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 DeviceID1 As PhoneId
Dim count As Int
Dim HttpClient1 As HttpClient
Dim request As HttpRequest
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
GPS1.Initialize("GPS")
GPS1.Start(0, 0) 'Listen to GPS with no filters.
count = 0
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub GPS_LocationChanged (Location1 As Location)
Dim DevID As String
Dim Device As Phone
Dim URL As String
Dim FURL As String
URL = "http://www.mywebsite.com/myscript/do.php"
count = count + 1
DevID = DeviceID1.GetDeviceId
If Location1.Accuracy <=100 Then
'call sub to send data to server
'ToastMessageShow("GPS Data Acc " & Location1.Accuracy & " " & Location1.Latitude & " " & Location1.Longitude & "DID " & DevID, True)
FURL = URL & "?lat=" & Location1.Latitude & "&lon=" & Location1.Longitude & "&did=" & DevID
ToastMessageShow(FURL, True)
'request.InitializeGet(URL & "?lat=" & Location1.Latitude & "&lon=" & Location1.Longitude & "&did=" & DevID)
request.InitializeGet(FURL)
request.Timeout = 10000 'set timeout to 10 seconds
HttpClient1.Execute(request, 1)
GPS1.Stop
End If
If count >15 Then
ToastMessageShow("No Accurate GPS Signal... Aborting", True)
GPS1.Stop
End If
If count Mod 5 = 0 Then
ToastMessageShow("Locating..." & count, True)
End If
End Sub
Sub HttpClient1_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim resultString As String
Result = Response.GetString("UTF8")
'Work with the result
End Sub
Sub HttpClient1_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Log("Error connecting: " & Reason & " " & StatusCode)
If Response <> Null Then
Log(Response.GetString("UTF8"))
Response.Release
End If
End Sub