java地理记录器:无法在getFromLocation()中传递LatLng
现在,我试图获取一个位置的国家/地区名称,但无法在getFromLocation()
中传递LatLng
。
我怎样才能解决这个问题
public void checkCountry(LatLng location) {
Geocoder gcd = new Geocoder(this, Locale.getDefaut());
List<Address> addresses = gcd.getFromLocation(location.latitude, location.logtitude, 1); //error here
String country = addresses.get(0).getCountryName();
错误是
Unhandled Exception: java.IO.Exception
getFromLocation() cannot be applied to: latitude double location.latitude longtitude double location.longtitude
我怎么了
# 1 楼答案
只需处理异常。要么扔,要么抓