2012-12-13 63 views

回答

2
Geocoder geoCoder = new Geocoder(getBaseContext(), Locale.getDefault()); 
    try { 
     List<Address> addresses = geoCoder.getFromLocation(latitude, longitude, 1); 
     if (addresses.size() > 0) { 
      String address = ""; 
      for (int index = 0; index < addresses.get(0).getMaxAddressLineIndex(); index++) 
       address += addresses.get(0).getAddressLine(index) + " "; 
      tv.setText(address);     Toast.makeText(getApplicationContext(),""+address,Toast.LENGTH_SHORT).show(); 
      Log.v("AddressTag", address); 
     } 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 

}

+0

沒有工作: 實際上您發佈的代碼與示例相似,實際上獲取座標的緯度,經度正在工作,但它通過IO例外:服務在地址部分不可用! – hero789