android – Capture the user's current location at a time interval and send it to the server

Question:

Hey guys.

So I need my app to send the user's location to my remote server every x minutes. I would like to know what would be the best workflow for this to happen correctly. I think the way is using Services and AlarmManager but I've never implemented something like that and I'm in doubt about the correct workflow to follow. Another important point is the need for the user's location to be sent to the remote server even if the app is not running.

Answer:

You will use an AlarmManager that starts a Service every X sec, as long as you want.

The Service must include a class that implements a location listener .

And you simply get the location within an activity of the Service and send it to the server using the AsyncTask .

Take a look at this link that can help you: link

Scroll to Top