I have a program where I want the user to have 3 options:
I can get 1 & 3 working by using the code here:
and using StartService and StopService.
2 is the what I have a prbolem with. Reading through the comments to this post the suggestion is that the lines:
and in the manifest
allow the background tracking.
How can I turn off the service Attribute programmtically so that the user can turn off background tracking but still have tracking whilst the app is active?
Cheers
- No location Tracking
- Location tracking whilst the app is foreground
- Location tracking with the app in background
I can get 1 & 3 working by using the code here:
Background location tracking
Simple example of a foreground service that keeps the process running in the background. The current location is shown in the persistent notification. The app starts at boot and theoretically should run all the time. It also schedules itself to run with StartServiceAt. This can help in cases...
www.b4x.com
2 is the what I have a prbolem with. Reading through the comments to this post the suggestion is that the lines:
B4X:
Service.StartForeground(nid, CreateNotification("..."))
B4X:
SetServiceAttribute(Tracker, android:foregroundServiceType, "location")
allow the background tracking.
How can I turn off the service Attribute programmtically so that the user can turn off background tracking but still have tracking whilst the app is active?
Cheers