Hello,
This is my service code which take GPS Coordinates every ten minutes . What I need is how can i stop the GPS after getting coordinates ?
Here I can see it is updating coordinates of each movements. I don't want to trace each movements, just current coordinates after that stop searching. and it will start searching after 10 minutes.
Also if I don't get the coordinates suppose I am inside home how can i stop searching ?
Please help me
Thanks and regards.
This is my service code which take GPS Coordinates every ten minutes . What I need is how can i stop the GPS after getting coordinates ?
Here I can see it is updating coordinates of each movements. I don't want to trace each movements, just current coordinates after that stop searching. and it will start searching after 10 minutes.
Also if I don't get the coordinates suppose I am inside home how can i stop searching ?
B4X:
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 TimerService As Timer
Dim Counter As Int
Counter=0
Dim Notification1 As Notification
End Sub
Sub Service_Create
TimerService.Initialize("TimerService",600000)
TimerService.Enabled=True
End Sub
Sub Service_Start (StartingIntent As Intent)
If GPS1.IsInitialized = False Then
GPS1.Initialize("GPS")
End If
If GPS1.GPSEnabled = False Then
ToastMessageShow("Please enable the GPS device.", True)
StartActivity(GPS1.LocationSettingsIntent)
Else
GPS1.Start(0,0)
End If
End Sub
Sub TimerService_Tick
If GPS1.IsInitialized = False Then
GPS1.Initialize("GPS")
End If
If GPS1.GPSEnabled = False Then
ToastMessageShow("Please enable the GPS device.", True)
StartActivity(GPS1.LocationSettingsIntent)
Else
GPS1.Start(0,0)
End If
End Sub
Sub Service_Destroy
GPS1.Stop
End Sub
Sub GPS_LocationChanged (Location1 As Location)
Main.SQL1.ExecNonQuery2("UPDATE settings SET latitude=?,longitude=?",Array As Object(Location1.Latitude,Location1.Longitude))
End Sub
Please help me
Thanks and regards.