#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
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 n As Notification
Dim GPS As Boolean
Dim GPS2 As String
Dim Latitude As String
Dim Longitude As String
Dim Speed As String
Dim Accuracy As String
Dim Altitude As String
Dim Heading As String
Dim Time As String
Dim lblSatellite As String
End Sub
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
GPS1.Initialize("GPS")
n.Initialize
End Sub
Sub Service_Start (StartingIntent As Intent)
If GPS1.GPSEnabled = False Then
GPS = False
GPS2 = "gpsno"
Else
GPS1.Start(0, 0) 'Listen to GPS with no filters.
GPS = True
GPS2 = "gpsok"
ServerJobs
End If
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
End Sub
Sub GPS_LocationChanged (Location1 As Location)
Latitude = NumberFormat(Location1.Latitude, 2, 6)
Longitude = NumberFormat(Location1.Longitude, 2, 6)
Speed = NumberFormat(Location1.Speed, 1,0)
Accuracy = NumberFormat(Location1.Accuracy, 1, 0)
Altitude = NumberFormat(Location1.Altitude, 1, 1)
Heading = NumberFormat(Location1.Bearing, 1, 0)
DateTime.DateFormat = "yyyy-MM-dd"
DateTime.TimeFormat = "HH:mm:ss"
Time = DateTime.Date(Location1.Time) & " " & DateTime.Time(Location1.Time)
End Sub
Sub GPS_UserEnabled (Enabled As Boolean)
End Sub
Sub GPS_GpsStatus (Satellites As List)
lblSatellite = "Satellites:" & CRLF
For i = 0 To Satellites.Size - 1
Dim Satellite As GPSSatellite
Satellite = Satellites.Get(i)
lblSatellite = lblSatellite & CRLF & Satellite.Prn & _
" " & Satellite.Snr & " " & Satellite.UsedInFix & " " & Satellite.Azimuth _
& " " & Satellite.Elevation
Next
End Sub
Sub ServerJobs
Dim Job1 As HttpJob
Job1.Initialize("MyJob", Me)
Job1.Download2("http://www.taksi-m.com.tr/track/server/http/android.php", Array As String("op", GPS2, "imei", Main.imeiService, "dt", Time, "lat", Latitude, "lng", Longitude, "altitude", Altitude, "angle", Heading, "speed", Speed, "params", Main.occupiedService, "event", Main.EventService))
Main.EventService = ""
Dim Job2 As HttpJob
Job2.Initialize("Job2", Me)
Job2.Download2("http://www.taksi-m.com.tr/track/server/s_service.php", Array As String("op", "chat_new_messages", "imei", Main.imeiService))
End Sub
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "Job1"
'print the result to the logs
'Log(Job.GetString)
Case "Job2"
'print the result to the log
Log(Job.GetString)
If Job.GetString > 0 Then
n.Icon = "icon"
n.SetInfo(Main.warningtitle1, Main.AlertMessage, Me)
n.Notify(1)
End If
Case "Job3"
'print the result to the logs
'Log(Job.GetString)
End Select
Else
Log("Error: " & Job.ErrorMessage)
End If
Job.Release
End Sub