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 where the OS kills the process.
Relevant example, based on this example, which plays music in the background: https://www.b4x.com/android/forum/threads/background-task.111106/#post-693336
There is a new requirement in Android 10+ devices.
In order for the location tracking to continue working in the background, if the user chooses the "allow while app is open" permission option we need to add this line to the manifest editor:
SetServiceAttribute(Tracker, android:foregroundServiceType, "location")
8.8 KB Views: 4,066