I'm trying to get my current GPS accuracy by using Location.getAccuracy()
. However, this is returning 1 (or sometimes 2) which doesn't seem possible. Google maps is telling me my current location accuracy is 40 meters.
Any thoughts?
int accuracy = (int) loc.getAccuracy();
// This will give me accuracy = 1
From the documentation of getAccuracy:
Returns the accuracy of the fix in meters.
Why doesn't it seem possible? A return-value of 1, sometimes 2 meters, is perfectly fine for GPS. With a good signal strength, and locks on multiple satellites, you can get that kind of accuracy.
(Besides, since you're casting to an int
your flooring the value. The accuracy may actually be for instance 1.9 meters.)
Is it possible that you are calling getAccuracy()
on the LocationProvider and not the Location? From the docs:
public abstract int getAccuracy ()
Since: API Level 1
Returns a constant describing horizontal accuracy of this provider. If the provider returns finer grain or exact location, ACCURACY_FINE
is returned, otherwise if the location is only approximate then ACCURACY_COARSE
is returned.
Where ACCURACY_FINE
and ACCURACY_COARSE
are defined as:
public static final int ACCURACY_COARSE
Since: API Level 1 A constant indicating an approximate accuracy requirement
Constant Value: 2 (0x00000002)
public static final int ACCURACY_FINE
Since: API Level 1 A constant indicating a finer location accuracy requirement
Constant Value: 1 (0x00000001)
40 meters looks more like cellular network accuracy, but not GPS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With