Add optional background location tracking with saving to layer, in the background and including on QField / Phone restart
Description:
It would be very beneficial to have an optional setting in QField that enables continuous location tracking, even when the app is running in the background, after a phone restart, or after QField is restarted. This location data would be automatically saved to a layer for later analysis.
Use case:
I want to track my position throughout the day and analyze patterns in my movement. By allowing QField to continuously track and save my location, even in the background or after a restart, this would make QField + QGIS highly flexible for long-term data collection and analysis.
Proposed feature:
Add an optional setting to enable background GPS tracking with saving directly to a layer.
Ensure this setting is disabled by default for privacy reasons.
Maintain location tracking after:
-
Phone restarts
-
QField restarts
Ensure the feature is optional and can be toggled on or off by users as needed.
Provide uninterrupted data logging without requiring manual intervention after restarts.
This enhancement would significantly improve the utility of location tracking for users needing seamless, continuous data collection.
Plattform Android
This Feature I am talking about
Hi,
I’m wondering if implementing a system to automatically start an app after a phone restart would be feasible or even practical. How would the app know when to launch, automatically activate the GPS, select the correct project (especially if multiple projects exist), and fill in the necessary fields? There could also be numerous potential challenges, such as how to handle field constraints if tracking is automatically initiated.
QField already offers an option to start tracking when a project is opened. You can have fields auto-complete and simply validate the new feature to begin tracking. It requires a few steps, but the process is fairly quick—I use it myself.
I’m not sure if the app stops tracking when running in the background, though. That would indeed be an issue.
comparing this app with another, qfield doesnt have an option to track in the background
About the other problems, about how the layer can be known: Limit the auto tracking to one Project(the Last opened). Also, on starting tracking, the layer is know, and whether constraints are fullfilled. (could add a toggle box, persist Tracking e.g.)
I come here to ask for same thing. Qfield has the defaut project feature and the feature to open it at launch
Beside that the tracking feature is not working even if the app is running but in background or when the phone is locked.
I am trying to have a polarstep like function on my side.
This is technically not that hard (on Android), but it would have QField cross into a different realm of privacy considerations according to app store rules.
FWIW, my view is that an app to just log location can be far simpler and lightweight, and doesn't need to be a GIS. Thus, it's best to keep this out of scope.
Regardless it would be nice for those that control the app to say one of
- great idea, pull request open
- too much scope creep, not going to do it, sorry. issue closed
@vincentBenet , @gdt , @werererer , you guys can try a PR build that introduces background tracking right here: https://github.com/opengisch/QField/pull/5917
Happy new year! :)
@vincentBenet , @gdt , @werererer , you guys can try a PR build that introduces background tracking right here: #5917
Happy new year! :)
QField~ Beta 5917 can't get the position always,and still can't tracking on background with my phone
@CyberWanli , could you a/ provide a video showing you starting tracking in QField, then putting it in the background, then coming back to it? Doesn't have to be long, 15-20 sec will do.
Do you see a notification popping up?
Finally, after you turn your positioning on, tracking on, put QField in the background and come back to it, could you send over a manual log by going into the message logs (through the main menu) and hitting the "send application log"? Use your github handle in the optional details field so I can easily find your log in the database.
Cheers.
@nirvn the following video showing my tracking in QField.
https://github.com/user-attachments/assets/723013ef-fa0d-4ff3-bed4-f8daa704ebff the application log is showed the link
@CyberWanli , could you turn this "send anonymized metrics" option on:
That'll make the "send application log" button visible here:
One thing I'm perplexed about is the absence of notification in your status bar. With that APK, you should see these notifications when you are in the background:
That makes me think maybe tge Redmi K40 didn't implement foreground service location support. We'd see that in the anonymized application metrics I'm referring to here.
@CyberWanli , I see your log, thanks. I'm noticing this here:
The FOREGROUND_SERVICE_LOCATION: not_granted, would be problematic as that's required.
@CyberWanli , did you accept the POST_NOTIFICATIONS permission when asked? That's required. As for the foreground service, I think your device runs on ~Android 11, which means that permission isn't required/used yet.
@CyberWanli , did you accept the POST_NOTIFICATIONS permission when asked? That's required. As for the foreground service, I think your device runs on ~Android 11, which means that permission isn't required/used yet.
@nirvn In the moning, I turned off the "allow notification badges" option. when i turn on , the screen can show the Qfield position result message, but Qfield didn't log the result to point or line tracking layer when the Qfield running in background.
@CyberWanli , OK, helpful, could you share the test project you're using here? Maybe there's something specific to your point layer.
One other test that'd be helpful to run: open the sample bees project, and use the Tracks line layer to track your position, and see if it works when put in background and coming back.
@CyberWanli , OK, helpful, could you share the test project you're using here? Maybe there's something specific to your point layer.
One other test that'd be helpful to run: open the sample bees project, and use the Tracks line layer to track your position, and see if it works when put in background and coming back. @nirvn ,thanks,the following is the test project. outsideTracking.zip
It seems what's asked for in this issue is implemented and the issue should be closed.
(Positioning is more aggressive than is reasonable, but there are separate issues for that.)
We do not have a recovery mechanism if the photo shutdowns while QField is in her background. We could transform this as en enhancement request to cover what's left to implement for that.