android - Location Updates -


iam developing app field signal strengths calculations every second using handler , during handler period records coordinates , record results & coordinates. works fine except when real testing , when increase speed of vehicle recorded coordinates not every second while times every 2-3-4 seconds not accepted me. code below:


final locationmanager locationmanager = (locationmanager) getsystemservice(context.location_service); locationmanager.requestlocationupdates(locationmanager.gps_provider, 0,     0, this);  publicvoid method_01(locationmanager locationmanager){  final handler handler = new handler(); handler.postdelayed(new runnable() {  @override public void run() { location locationdatarate =     locationmanager.getlastknownlocation(locationmanager.gps_provider); double latitude = locationdatarate.getlatitude(); double longitude = locationdatarate.getlongitude(); x=y+1; save file (latitude,longitude,x); handler.postdelayed(this, 1000); } }, 1000);  } 

i have tried change time , min. distance (1000,0)

first of all, if want receive update every 1 second, should not request more frequent updates. therefore:

locationmanager.requestlocationupdates(locationmanager.gps_provider, 1000, 0, this); 

anyway, best practice handling location updates not persistently looping getlastknownlocation implementing callback of location updates. there bundle of examples here.

to question, in doc state interval between updates in never guaranteed:

the location update interval can controlled using mintime parameter. elapsed time between location updates never less mintime, although can more depending on location provider implementation , update interval requested other applications.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -