Solution 1 :
For location update, you can use fused location provider to get location.
In this codelab, task 4.2: https://codelabs.developers.google.com/codelabs/advanced-android-training-device-location/index.html?index=..%2F..advanced-android-training#5. You will see create location request, you can set interval for it. And for run in background use JobIntentService or Work Manager will solve it. I need more info about your code, i understand why it not work.
We have to schedule the process in which we have to call the API(send user location to server) in every 15 min in all the modes like(In foreground, background, and in kill mode).
We have tried so many solution like:
But After 1-2 hours our service is stop automatically.
Its behaving differently in different android devices(with different OS also).
We need to run the background process for the life time and call the API in every 15 min.
Comment posted by ADM
There is not such thing as life time . Your best shot is Work manager one time Job and set subsequent job after its completed. This is also because there is a need of a Network Constraint in your case. On other hand Foreground service is a bad idea in this case .