안녕하세요~ 초보 안드로이드 공부하는 학생 입니다..
책보고 공부중인데요..이 문제는 절대 풀리지가 않아서..고수님들께 질문 올립니다.
private void updateWithNewLocation(Location location) {
TextView myLocationText = (TextView)findViewById(R.id.myLocationText);
String latLongString;
String addressString = "No address found";
if (location != null) {
double lat = location.getLatitude();
double lng = location.getLongitude();
latLongString = "Lat:" + lat + "\nLong:" + lng;
Geocoder gc = new Geocoder(this, Locale.getDefault());
try {
List<Address> addresses = gc.getFromLocation(lat, lng, 1);
StringBuilder sb = new StringBuilder();
if (addresses.size() > 0) {
Address address = addresses.get(0);
for (int i = 0; i < address.getMaxAddressLineIndex(); i++){
sb.append(address.getAddressLine(i)).append("\n");
}
sb.append(address.getLocality()).append("\n");
sb.append(address.getPostalCode()).append("\n");
sb.append(address.getCountryName());
}
addressString = sb.toString();
} catch (IOException e) {}
} else {
latLongString = "No location found";
}
myLocationText.setText("Your Current Position is:\n" + latLongString + "\n" + addressString);
}
이렇게 실행시..문제 없이 실행은 되는데요..경도와 위도 값을 센드 했을 경우에..
경도와 위도 값은 제대로 찍어주는데요...
경도와 위도에 해당하는 주소값은 찍어주지 못하고 계속 No address found 을 찍어주네요..
고수님들..저와 같은 경험이 있으신분들 도움좀 주세요 ^^;
감사합니다~~