문제

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.

도움이 되었습니까?

해결책

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).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top