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 sendcoordinates As String
Dim username, password As String
Dim db As SQL
Dim Cursor1 As Cursor
Dim cursorposition As Int
End Sub
Sub Service_Create
gps1.Initialize("gps1")
Log("GPS_Tracker Service started")
If gps1.GPSEnabled = False Then StartActivity(gps1.LocationSettingsIntent)
db.Initialize(File.DirInternal, "cyprus.db", False)
Cursor1 = db.ExecQuery("SELECT UserName, Password FROM logininfo")
'gps1.Start(0, 0) 'Listen to GPS with no filters.
End Sub
Sub Service_Start (StartingIntent As Intent)
gps1.Start(0, 0)
Log("finding location....")
StartServiceAt("", DateTime.Now + 30 * 1000, True)
Sub GPS1_LocationChanged (Location1 As Location)
Dim coordinates As HttpJob
coordinates.Initialize("location", Me)
Dim time1 As String
ToastMessageShow(Location1.Latitude & " " & Location1.Longitude, False)
Log(Location1.Latitude & " " & Location1.Longitude)
Log(Location1.Speed * 3.6)
gps1.Stop
DateTime.DateFormat = "yyyy-MM-dd-HH:mm:ss"
time1 = DateTime.Date(DateTime.Now)
cursorposition = Cursor1.RowCount - 1
Cursor1.Position = cursorposition
username = Cursor1.GetString("UserName")
password = Cursor1.GetString("Password")
'Next
sendcoordinates = "http://xxxxxxxxxxxxx.net/tracking/controller.php?action=coordinate_update&username=" & username & "&password=" & password & "&i_user_id=3&s_lat=" & Location1.Latitude & "&s_long=" & Location1.Longitude & "&s_accuracy=5" & "&s_speed=" & (Location1.Speed * 3.6) & "&d_time=" & time1 & "&b_from_saved=0"
Log(sendcoordinates)
coordinates.Download(sendcoordinates)
End Sub
End Sub