Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove update when location not changed in long time in android

I created an android app to get a user's location from LocationManager and Locationlistener with a GPS provider. My minDistance parameter in requestLocationUpdates is 100 (that means that the location is not updated when the distance < 100 meters), and I want to remove updatelocation automatically when the location is not changed (or no new location is received in onLocationChanged) after a long time (ex: 5 minutes), for energy saving purposes.

like image 877
Tuan Anh Dao Ngoc Avatar asked Jan 25 '26 00:01

Tuan Anh Dao Ngoc


1 Answers

Write a service to collect data from GPS. Run a thread for 5 mins in which request for GPS coordinates after every minutes, if all the reading are same in those 5 mins. Stop the service, and then you can start it again whenever you want.

like image 186
ShahrozKhan91 Avatar answered Jan 27 '26 13:01

ShahrozKhan91