Have been trying to use fused location, and location services in order to get a location in the background and when the app is not running. Unfortunately, everything worked fine until android 8 came. I have an app that needs to send the location to a server at least every minute when the app is not in the background and when not running. Fused location is not giving the location as I set in the properties. Thanks.
Asked
Active
Viewed 192 times
2 Answers
0
So, in android 8 and above, the best way to get the location in the background, or when the app is not running, would be using the Alarm Manager. The minimum periodic time alarm can be turned on is 60 sec, this is the best way with the minimum time to update the server with the location.

Udi Levy
- 611
- 1
- 6
- 7
0
I recommend using JobScheduler.
You can reschedule your Job Service to do its Job every minute.

Mehmet Emre Kutluca
- 18
- 5
-
I did use JobScheduler before but the minimum period of time to run the job is about 15 minutes. So the minimum period of time if found was using Alarm Manager. Check it... – Udi Levy Nov 16 '18 at 15:53
-
It is possible to reschedule Job programmatically. When your Job finishes, you can add a method to reschedule itself. – Mehmet Emre Kutluca Nov 18 '18 at 00:22