Android service always with GPS

I created an Android application that is working quite well so far. It contains a local service, which is responsible for obtaining the location of users every couple of minutes and transmitting it via UDP to the collection server, which is displayed on the map of the web application.

The application should constantly work if the user does not explicitly write out the application. Currently, it seems that the OS is shutting down the service and restarting it as necessary. I see this because usually it will report its location sequentially every 2 minutes. Instead, there are gaps in these intervals.

So, I'm looking for some tips on how I can write a service that, unfortunately, can always work and combine the location service to send accurate corrections with an interval of 2 minutes.

I have a well-functioning code base so far, so if a demonstration of where I am with the code helps, feel free to ask.

Thanks in advance to those who reach out.

0
source share
1 answer

It is best to use AlarmManager to wake up every two minutes, do some processing, and quickly go back to sleep.

, , , , .

0

All Articles