我想從Geocoder獲取位置地址,我可以獲取經度和緯度,但它返回的地址長度爲零。Android地址解析器返回空地址
這裏是我的代碼片斷
double longi = location.getLongitude();
double latt = location.getLatitude();
Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.ENGLISH);
String add="";
try {
List<Address> address = geocoder.getFromLocation(latt/1E6,longi/1E6, 1);
System.out.println("in location listener "+address.size());
int i=0;
if(address.size()>0)
{
for(i=0;i<address.get(0).getMaxAddressLineIndex();i++)
{
add += address.get(0).getAddressLine(i);
}
Toast toast = new Toast(getApplicationContext());
toast.makeText(getApplicationContext(), add, Toast.LENGTH_LONG).show();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
請幫我把它正確。提前致謝!
[看一看這個答案](http://stackoverflow.com/a/9075559/593709) –