How to Store Location information every 15 minutes

2019-04-17 05:07发布

问题:

I need to work Location API for android where first the data is to be stored on Local Sqlite datbase in android itself each 15 minutes and then send it to a server, so that data can be tracked offline too.

Any suggestions, code or help is really appreciated !

回答1:

You, can simply create a background service then implements a location listener. In that location listener, you can set the time interval in the requestLocationUpdate method to ping the GPS at particular time intervals. or you can use timertask to send gps at particular intervals Here is a location manager instance:

lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, timeinterval2, 0, locationListener);

You can send that location to the server from the service. You can also send notifications to launch the app.



回答2:

This question is many time asked in SO,

Use Alarm Manager and Service for this,

And go through this question

How can i send latitude longitude of android device every 15minute to php web service and How to get gps coordinates every minute in Android?