我的代码:
try
{
Geocoder geocoder;
List<Address> addresses;
geocoder = new Geocoder(LocationActivity.this, Locale.getDefault());
addresses = geocoder.getFromLocation(longitude,latitude,1);
Toast.makeText(LocationActivity.this, addresses.size() + "", Toast.LENGTH_LONG).show();
String address = addresses.get(0).getAddressLine(0);
String city = addresses.get(0).getAddressLine(0);
String country = addresses.get(0).getAddressLine(0);
Toast.makeText(LocationActivity.this, address + " " + city + " " + country, Toast.LENGTH_LONG).show();
}
catch(Exception e)
{
Toast.makeText(LocationActivity.this,e.toString(), Toast.LENGTH_LONG).show();
}
这是我从经度和纬度获取地址的代码。但每次addresses.size返回0
谁能帮我这个