Reputation: 99
I am using Gps and fetching location and sending to server after each 10 minutes but do to Gps ,battery draining.So for this i want that after each 10 minutes Gps should on and fetch location and after this Gps should off itself.
Upvotes: 0
Views: 195
Reputation: 93678
Set an Alarm via AlarmManager for every 10 minutes. In the alarm, call locationManager.requestSingleUpdate for the GPS provider. That will turn on the GPS long enough to get a single fix, then turn it off (unless some other program is using it). When it gets a fix it will call you via the callback you register in requestSingleUpdate. Then you can do whatever you need to with the result (such as sending it to a server via an AsyncTask).
Upvotes: 1