来源比较清楚。
/**
* Indicates the desired horizontal accuracy (latitude and longitude).
* Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_MEDIUM},
* {@link #ACCURACY_HIGH} or {@link #NO_REQUIREMENT}.
* More accurate location may consume more power and may take longer.
*
* @throws IllegalArgumentException if accuracy is not one of the supported constants
*/
public void setHorizontalAccuracy(int accuracy) {
if (accuracy < NO_REQUIREMENT || accuracy > ACCURACY_HIGH) {
throw new IllegalArgumentException("accuracy=" + accuracy);
}
mHorizontalAccuracy = accuracy;
}
/**
* Returns a constant indicating the desired horizontal accuracy (latitude and longitude).
* Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_MEDIUM},
* {@link #ACCURACY_HIGH} or {@link #NO_REQUIREMENT}.
*/
public int getHorizontalAccuracy() {
return mHorizontalAccuracy;
}
/**
* Indicates the desired accuracy for latitude and longitude. Accuracy
* may be {@link #ACCURACY_FINE} if desired location
* is fine, else it can be {@link #ACCURACY_COARSE}.
* More accurate location may consume more power and may take longer.
*
* @throws IllegalArgumentException if accuracy is not one of the supported constants
*/
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;
}
}
/**
* Returns a constant indicating desired accuracy of location
* Accuracy may be {@link #ACCURACY_FINE} if desired location
* is fine, else it can be {@link #ACCURACY_COARSE}.
*/
public int getAccuracy() {
if (mHorizontalAccuracy >= ACCURACY_HIGH) {
return ACCURACY_FINE;
} else {
return ACCURACY_COARSE;
}
}
那么区别是什么呢 ?请注意,它们采用不同的常数 - 是否可以/希望用某种常数组合来指定两者?
好吧,它没有区别 -setAccuracy()
只需设置mHorizontalAccuracy
为要么ACCURACY_HIGH
-ACCURACY_LOW
如果您愿意ACCURACY_MEDIUM
,或者NO_REQUIREMENT
您必须调用setHorizontalAccuracy()
。
所以内部精度只是“水平精度”。现在,如果有人知道他们为什么需要两者,我会接受他/她的回答-暂时关闭。