Reputation: 3296
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
Upvotes: 9
Views: 9085
Reputation: 706
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)
Upvotes: 3
Reputation: 56
I usually have 6-9 satelites visible (Scandinavia) and get around 2.0 meters for getAccuracy() - and it turns out, in practice, to be around +|- 40 cm accurate in reality.
Upvotes: 1
Reputation: 5593
40 meters looks more like cellular network accuracy, but not GPS.
Upvotes: 1
Reputation: 421040
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.)
Upvotes: 8