I'm working on a research project which uses Android as control and computation platform and predicts when a user returns home. To actually achieve a high location-prediction accuracy I need frequent location updates. As GPS is of course not exactly good for long stand-by time I implemented a method which changes the frequency of the location updates based on the movement of the mobile phone. Meaning if the user moves for more than a minute, which would indicate movement of the user, the locationEventListener is queried every minute and GPS is used if available. If the phone is not moved the update frequency goes up to 5 minutes and the network provider is used.
To change the frequency I use the removeUpdates method of the LocationManager:
- Code: Select all
locationManager.requestLocationUpdates(provider, 60000, 0, locationEventListener);
In the debug console of Eclipse I see that adding and removing of the EventListener works quite well and the long update cycle too, but I have troubles with the short update cycle which uses GPS. Instead of querying the GPS every minute it's doing it every second or so. (I see the nice flashing GPS symbol) This of course puts quite a strain on the battery, so that my study participants only get about 8 hrs out of their phone.
Did anyone had similar problems in the past? And is my way of removing and adding the EventListener possible at all or do I maybe create some strange side-effects with it?
Thanks for your help,