Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
werererer opened this issue Oct 17, 2024 · 16 comments

Comments

@werererer
Copy link

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 werererer changed the title Add optional background location tracking with saving to layer, enabled by default, including on QField restart Add optional background location tracking with saving to layer, in the background and including on QField restart Oct 17, 2024
@werererer werererer changed the title Add optional background location tracking with saving to layer, in the background and including on QField restart Add optional background location tracking with saving to layer, in the background and including on QField / Phone restart Oct 17, 2024
@werererer
Copy link
Author

werererer commented Oct 17, 2024

Screenshot_20241017_101314.jpg

This Feature I am talking about

@Ipickedausername
Copy link

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.

@werererer
Copy link
Author

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
Copy link
Author

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

@vincentBenet
Copy link

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.

@gdt
Copy link

gdt commented Dec 28, 2024

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

@nirvn
Copy link
Member

nirvn commented Jan 2, 2025

@vincentBenet , @gdt , @werererer , you guys can try a PR build that introduces background tracking right here: #5917

Happy new year! :)

@CyberWanli
Copy link

@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

@nirvn
Copy link
Member

nirvn commented Jan 7, 2025

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

@CyberWanli
Copy link

@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

@nirvn
Copy link
Member

nirvn commented Jan 7, 2025

@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
Copy link
Member

nirvn commented Jan 7, 2025

@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
Copy link
Member

nirvn commented Jan 7, 2025

@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
Copy link

CyberWanli commented Jan 7, 2025

@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

@nirvn
Copy link
Member

nirvn commented Jan 7, 2025

@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
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants