开发者

Android: How to get the most accurate location from GPS

I have used this code

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
                500, 50, this);

to get my location using GPS. From what I understood, this code updates the GPS every 500milliseconds until the accuracy is开发者_JS百科 about 50ms. Right? Now how do I know when it has achieved this accuracy? So that I can send the most accurate location in a text message.


500 is the minimum interval for notifications and is only a hint.

As can be seen in the javadocs :

the minimum time interval for notifications, in milliseconds. This field is only used as a hint to conserve power, and actual time between location updates may be greater or lesser than this value.

So you can (and will) see variations on this interval (LocationListener will not always be called with an exact 500ms interval)

50 is the minDistance and according to the docs : the minimum distance interval for notifications, in meters. So this doesn't effect the accuracy, it only defines the trigger for location updates. (if you move minDistance, then a trigger occurs). As such, this does not influence the accuracy.

However, your locationlistener will return an android.location.Location, and that exposes an accuracy (the accuracy of the fix in meters)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜