Location Android manager? Experiences

1

I have developed a Gps application that sends information to Mysql every 10 sec through the locationmanager. According to your experience, how much is it possible to reduce this time?

    
asked by David Peña 13.09.2016 в 01:26
source

2 answers

3

Interesting question, when you use LocationManager you have two important variables that are minDistance which is the minimum interval in which notifications are obtained and minTime which is the minimum time interval for notifications.

This is an example, I define readings every 10 minutes (60,000 milliseconds) and every 10 meters:

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 10, this.locationListener);

How to optimize, depends on the requirement of your application, you must take into account that if you require more samples, or less distance and less time to obtain the readings, battery consumption is indirectly proportional.

I recommend you check: Location Strategies. (English).

It is important that you now implement FusedLocationProviderApi instead of LocationManager , since this class optimized for this task and a very important point is that it creates a cache where it stores the readings that are used by all the applications that require it, unlike LocationManager that by each application generates a process of obtaining localization which is expensive for the application.

bye bye LocationManager ...

    
answered by 13.09.2016 / 02:18
source
0

I started testing with 1 second 0 meters, everything was fine until I had 5km the server began to saturate and I received the messages late, change then to 5sec 0 meters and the server has been stable I have traveled 20km of test and it has not been delayed no shows. locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 0, this.locationListener);

Conclusion The transfer speed usually varies constantly due to the fact that the mobile is connected and disconnected from one antenna to another. As the time lapse is so short, it starts sending messages late.

    
answered by 14.09.2016 в 23:38