2
Android 코드를 사용하여 1 분마다 GPS를 계속 가져 오려고합니다. 그것이 하늘을 깨끗하게 할 때 아주 잘 작동합니다. 그러나 때로는 구름이 많을 때 위도경도를 얻을 수 없습니다. 이런 경우 GPS Co-Ordinates를 어떻게해야합니까? 대체 등흐린 날씨에 GPS Co-Ordinates가 작동하지 않습니다.
Android 코드를 사용하여 1 분마다 GPS를 계속 가져 오려고합니다. 그것이 하늘을 깨끗하게 할 때 아주 잘 작동합니다. 그러나 때로는 구름이 많을 때 위도경도를 얻을 수 없습니다. 이런 경우 GPS Co-Ordinates를 어떻게해야합니까? 대체 등흐린 날씨에 GPS Co-Ordinates가 작동하지 않습니다.
사용 와이파이 위치 및 세포 타워 위치 : 또한 http://developer.android.com/guide/topics/location/obtaining-user-location.html
private static final int TWO_MINUTES = 1000 * 60 * 2;
/** Determines whether one Location reading is better than the current Location fix
* @param location The new Location that you want to evaluate
* @param currentBestLocation The current Location fix, to which you want to compare the new one
*/
protected boolean isBetterLocation(Location location, Location currentBestLocation) {
if (currentBestLocation == null) {
// A new location is always better than no location
return true;
}
// Check whether the new location fix is newer or older
long timeDelta = location.getTime() - currentBestLocation.getTime();
boolean isSignificantlyNewer = timeDelta > TWO_MINUTES;
boolean isSignificantlyOlder = timeDelta < -TWO_MINUTES;
boolean isNewer = timeDelta > 0;
// If it's been more than two minutes since the current location, use the new location
// because the user has likely moved
if (isSignificantlyNewer) {
return true;
// If the new location is more than two minutes older, it must be worse
} else if (isSignificantlyOlder) {
return false;
}
// Check whether the new location fix is more or less accurate
int accuracyDelta = (int) (location.getAccuracy() - currentBestLocation.getAccuracy());
boolean isLessAccurate = accuracyDelta > 0;
boolean isMoreAccurate = accuracyDelta < 0;
boolean isSignificantlyLessAccurate = accuracyDelta > 200;
// Check if the old and new location are from the same provider
boolean isFromSameProvider = isSameProvider(location.getProvider(),
currentBestLocation.getProvider());
// Determine location quality using a combination of timeliness and accuracy
if (isMoreAccurate) {
return true;
} else if (isNewer && !isLessAccurate) {
return true;
} else if (isNewer && !isSignificantlyLessAccurate && isFromSameProvider) {
return true;
}
return false;
}
/** Checks whether two providers are the same */
private boolean isSameProvider(String provider1, String provider2) {
if (provider1 == null) {
return provider2 == null;
}
return provider1.equals(provider2);
}
,이 게시물을 체크 아웃 ... 모두 대답을 적용 할 수 있습니다 : Android: GPS fallback from fine to coarse
당신은 때 GPS에 대처하는 방법을 알아 내야한다 좌표는 사용할 수 없습니다. 지리적 위치가 불가능한 조건이 항상 있습니다. –
그 사실을 알고 있지만 그 경우 어떻게해야합니까? – Android
귀하의 신청서를 모릅니다. 나는 말할 수 없습니다. –