QField icon indicating copy to clipboard operation
QField copied to clipboard

Add optional background location tracking with saving to layer, in the background and including on QField / Phone restart

Open werererer opened this issue 1 year ago • 18 comments

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

werererer avatar Oct 17 '24 02:10 werererer

Screenshot_20241017_101314.jpg

This Feature I am talking about

werererer avatar Oct 17 '24 02:10 werererer

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.

Ipickedausername avatar Oct 17 '24 03:10 Ipickedausername

Screenshot_20241017_111558_Permission controller.jpg

Screenshot_20241017_111636_Permission controller.jpg

comparing this app with another, qfield doesnt have an option to track in the background

werererer avatar Oct 17 '24 03:10 werererer

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.)

werererer avatar Oct 17 '24 03:10 werererer

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.

vincentBenet avatar Oct 30 '24 17:10 vincentBenet

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

gdt avatar Dec 28 '24 18:12 gdt

@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! :)

nirvn avatar Jan 02 '25 03:01 nirvn

@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 微信图片_20250107100625 微信图片_20250107100635 微信图片_20250107100644

CyberWanli avatar Jan 07 '25 02:01 CyberWanli

@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 avatar Jan 07 '25 02:01 nirvn

@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 avatar Jan 07 '25 03:01 CyberWanli

@CyberWanli , could you turn this "send anonymized metrics" option on:

image

That'll make the "send application log" button visible here:

image

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:

image

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.

nirvn avatar Jan 07 '25 03:01 nirvn

@CyberWanli , I see your log, thanks. I'm noticing this here:

image

The FOREGROUND_SERVICE_LOCATION: not_granted, would be problematic as that's required.

nirvn avatar Jan 07 '25 04:01 nirvn

@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 avatar Jan 07 '25 04:01 nirvn

@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. 微信图片_20250107154926 微信图片_20250107154937 微信图片_20250107155025 89b381c3-b0f1-4afe-bd7c-2b3b28287877

CyberWanli avatar Jan 07 '25 07:01 CyberWanli

@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 avatar Jan 07 '25 07:01 nirvn

@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

CyberWanli avatar Jan 07 '25 08:01 CyberWanli

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.)

gdt avatar Jul 23 '25 23:07 gdt

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.

nirvn avatar Jul 24 '25 00:07 nirvn