1
這是我的代碼 它沒有任何錯誤,但如何在android中的模擬器上使用緯度和經度獲取完整的地址地址?
它顯示在textView「無地址返回!」
double lat = 18.520430300000000000, log = 73.856743699999920000;
String address = null;
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
StringBuilder sb = null;
try {
List<Address> addresses = geocoder.getFromLocation(lat, log, 1);
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)+ ",");
txtAdd.setText("Address :"+sb);
}
else{
txtAdd.setText("No Address returned!");
}
} catch (Exception e) {
// TODO Auto-generated catch block
/*e.printStackTrace();*/
txtAdd.setText("Canont get Address!");
}
PLZ給我這個
在此先感謝解決方案...