在Criteria
类中,有两个常量ACCURACY_HIGH
和ACCURACY_FINE
,它们显然用于要求LocationManager
返回更高精度的位置更新。下面是documentation对这些常数的说明:
公共静态最终整数精度(添加到API级别1中)
A constant indicating a finer location accuracy requirement
Constant Value: 1 (0x00000001)
公共静态最终整数精度高(添加在API级别9中)
a constant indicating a high accuracy requirement - may be used for horizontal, altitude, speed or bearing accuracy. For horizontal and vertical position this corresponds roughly to an accuracy of less than 100 meters.
Constant Value: 3 (0x00000003)
有人知道这两个常数中的哪一个提供(即需要)最高的精确度吗?
最佳答案
从我在源代码中看到,accurity_fine和accurity_coarse分别被归为1和2的常量值。精度低、中、高与定值1、2、3组合在一起。
SetAccuracy期望并返回粗糙或精细,而SetVerticalAccuracy、SetHorizontalAccuracy、SetSpeedAccuracy和SetBearingAccuracy期望低、中或高。此外,当您调用setaccurity时,它会像这样设置水平精度:
public void setAccuracy(int accuracy) {
if (accuracy < NO_REQUIREMENT || accuracy > ACCURACY_COARSE) {
throw new IllegalArgumentException("accuracy=" + accuracy);
}
if (accuracy == ACCURACY_FINE) {
mHorizontalAccuracy = ACCURACY_HIGH;
} else {
mHorizontalAccuracy = ACCURACY_LOW;
}
}
我真的很困惑,但我希望我能帮你澄清一下。这里有一个指向grepcode中源代码的链接,您可以下载它,然后自己查看是否在本地没有源代码。