I have this project that is already done and working. It's an Android app made in Unity that tracks the GPS coordinates and draws these coordinates while recording a trip/journey.
But there is a problem with this app (due to the limitation of Unity apps not being able to run in the background). When the app is out of focus or the screen is off, no coordinates are registered, only when the app resumes from the pause state, or the user turns on the screen, the gps coordinates start updating again (missing the ones that were supposed to register when the app was paused).
As far as I know, the only workaround possible is to create an Android service that is invoked by the app when the trip/journey starts, this service will then register all GPS coordinate updates and deliver them to the app. This way if the app is out of focus, the GPS coordinate updates will continue to be collected in the background, until the app resumes from the pause state and retrieves all the coordinates being collected by the service.