I'm havin an app based on recording gps coordinates on an set interval of 60 secs. A background thread is the location listener that reacts on the changes. The listening thread is woken up each 60 seconds as well.

I want to make this draw as little energy as possible while still keeping the update interval. I start my app by registering a locationmanager as shown below. Is this the best method or would I save anergy by creating a new location manager each 60 secs when I want to get the position?

LocationManager locationManager = (LocationManager)

this.getSystemService(Context.LOCATION_SERVICE);    
locationManager.requestLocationUpdates(locationProvider,60000,10,updaterThread);

The precison is not particularily high (~ 20 meters) but the need to have regular update intervals of not more than 60 secs is very important.

有帮助吗?

解决方案

you should look at using the new Fused Location API it is designed specifically for this.

basically all you have to do is connect to the location manager and once you are connected you can just call it when you want to get your location

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top