Android Question GPS Recorder Service: Unusual Behaviour

RobertK

Member
Licensed User
Hello!

My app requires a GPS Recorder service which continuously writes GPS data to internal storage throughout the life of the process.

The following code works well when the Main activity is active. However, even though the GpsRecorder service is not destroyed, recording stops when the Main activity is paused, and resumes when the activity resumes.

Main:
Sub Activity_Create(FirstTime As Boolean)
    StartService(GpsRecorder)
End Sub

GpsRecorder Service:
Sub Process_Globals
    Private GpsLock As PhoneWakeState
    Dim MyGps As GPS
    Dim GpsData As GpsDataStruct
End Sub

Sub Service_Start (StartingIntent As Intent)
    GpsLock.PartialLock
    MyGps.Start(0, 0)
    ToastMessageShow("GPS recorder started", False)
End Sub

Sub Service_Destroy
    ToastMessageShow("GPS recorder stopped", False)
End Sub

Sub MyGps_LocationChanged(Loc As Location)
    GpsData.GpsUtc = Loc.Time
    GpsData.Lat = Loc.Latitude
    GpsData.Lon = Loc.Longitude
    WriteGpsBin
End Sub

Sub WriteGpsBin
    ' Writes GPS data to internal storage
End Sub

What seems particularly unusual is that when another app that records GPS data (Oruxmaps, www.oruxmaps.com) is running on the same device at the same time, then my GPS recorder does not pause, and performs just as it should.

There is a good deal of information about using GPS on the Forum but I have not been able to find posts which address this specific issue. Any advice would be gratefully appreciated.
 

DonManfred

Expert
Licensed User
Longtime User
 
Upvote 0

RobertK

Member
Licensed User
Thank you Manfred, I will look through the example and implement the required changes.

But how do you explain the interaction between the two concurrently running apps regarding pausing of the GPS recorder service?
 
Upvote 0
Top