56081

Clarification on min distance on LocationManager.requestLocationUpdates method, min Distance paramet

I researched online and saw that Location Manager.requestLocationUpdates method and saw that it took an argument of minDistance. The definition that the site(http://blog.doityourselfandroid.com/2010/12/25/understanding-locationlistener-android/) gave me for that argument was "minimum distance interval for notifications" with an example of 10 meters. Can anyone clarify what that means? Everytime i move 10 meters with a phone, i get an gps update?

Answer1:

Yes, essentially this means that if the platform observes your current position as being more than minDistance from the last location that was saved by the platform, your listener will get notified with the updated position. Note that these two positions don't necessarily need to be sequential (i.e., there could be a number of small displacements that eventually add up to minDistance, and the location that finally exceeds the threshold will be the one reported to the app).

The actual platform code can be seen on Github, which I've also pasted below:

private static boolean shouldBroadcastSafe( Location loc, Location lastLoc, UpdateRecord record, long now) { // Always broadcast the first update if (lastLoc == null) { return true; } // Check whether sufficient time has passed long minTime = record.mRequest.getFastestInterval(); long delta = (loc.getElapsedRealtimeNanos() - lastLoc.getElapsedRealtimeNanos()) / NANOS_PER_MILLI; if (delta < minTime - MAX_PROVIDER_SCHEDULING_JITTER_MS) { return false; } // Check whether sufficient distance has been traveled double minDistance = record.mRequest.getSmallestDisplacement(); if (minDistance > 0.0) { if (loc.distanceTo(lastLoc) <= minDistance) { return false; } } ...

Note that minDistance parameter only affects when your app gets notified if the value is greater than 0.

Also please be aware that with all positioning systems there is a significant level of error when calculating locations, so with small minDistance values you may get notified frequently, but these notifications may be error in positioning calculations, not true user movement.

Recommend

  • Powershell: Creating Custom DataGridView
  • Special characters in property name
  • Override mylocation button in android Google maps api v2
  • Detect when the drawer is closed while using MMDrawerController
  • Celery + Redis - .get() hangs indefinitely after running smoothly for ~70 hours
  • Selecting TOP 4 records from multiple SQL Server tables. Using vb.net
  • GPS coordinates on mobile phones
  • Delphi TCollection - Possible to prevent changing items in run-time?
  • SoundPool is loading sounds but every time I play it it says “sample ___ is not ready”?
  • Read stdin in chunks in Bash pipe
  • Floating-point number in Excel
  • How to resend request with android volley when not authorized
  • HTML code to upload images
  • Removing event listeners on automatically created multiple elements
  • NSMutableArray Access Issue
  • Nodejs bluebird promise fails while processing image
  • Quick Question About Get and Set
  • Find VMID for running instance
  • ConnectivityManager.CONNECTIVITY_ACTION deprecated
  • Java making confirming exit
  • Zoom in and out of jPanel
  • How to revert to previous XCode version?
  • Firefox Extension - Monitor refresh and change of tab
  • Saving Changes After In-App Purchase Has Been Purchased
  • Blackberry - Custom EditField Cursor
  • Body moving without any force applied? (Box2d)
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • recyclerView does not call the onBindViewHolder when scroll in the view
  • Validaiting emails with Net.Mail MailAddress
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • Javascript + PHP Encryption with pidCrypt
  • To display the title for the current loaction in map in iphone
  • How to get next/previous record number?
  • Confusion with PayPal's monthly billing cycle
  • retrieve vertices with no linked edge in arangodb
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • Understanding cpu registers
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Android Google Maps API OnLocationChanged only called once
  • Add sale price programmatically to product variations