2
안드로이드에서 GPS를 사용하지 않고 GEO 좌표 (경도 & 경도)를 얻는 방법은 무엇입니까? 제안 사항 ...Android가 현재 GEO 좌표를 얻습니다.
안드로이드에서 GPS를 사용하지 않고 GEO 좌표 (경도 & 경도)를 얻는 방법은 무엇입니까? 제안 사항 ...Android가 현재 GEO 좌표를 얻습니다.
/**
* This is a fast code to get the last known location of the phone. If there
* is no exact gps-information it falls back to the network-based location
* info. This code is using LocationManager. Code from:
* http://www.androidsnippets.org/snippets/21/
*
* @param ctx
* @return
*/
public static Location getLocation(Context ctx) {
LocationManager lm = (LocationManager) ctx
.getSystemService(Context.LOCATION_SERVICE);
List<String> providers = lm.getProviders(true);
/*
* Loop over the array backwards, and if you get an accurate location,
* then break out the loop
*/
Location l = null;
for (int i = providers.size() - 1; i >= 0; i--) {
l = lm.getLastKnownLocation(providers.get(i));
if (l != null)
break;
}
return l;
}
감사합니다. 그것은 나를 위해 일합니다. – BlaShadow