【发布时间】:2019-08-18 10:05:08
【问题描述】:
世界你好!
我正在尝试开发一个应用程序,它可以根据纬度和经度显示波斯地址。 我应该如何实现这个?
我这样使用 GeoCoder 类;
public String getAddress(Context context ,double latitude , double longitude)
{
String fullAddress = null ;
try {
Geocoder geocode = new Geocoder(context, new Locale("fa"));
List<android.location.Address> addresses = geocode.getFromLocation(latitude, longitude, 1);
Address ad = addresses.get(0);
fullAddress = ad.getAddressLine(0);
}
catch (IOException exc)
{
fullAddress =exc.getMessage();
exc.printStackTrace();
}
return fullAddress;
}
这就是我得到的。
W/System.err: java.io.IOException: grpc failed
W/System.err: at android.location.Geocoder.getFromLocation(Geocoder.java:136)
如果我将 Locale.getDefault() 作为 Geocoder Ctor 参数发送,结果不会改变
这段代码有什么问题?
感谢您的回答
【问题讨论】:
标签: java android google-maps-api-3 google-geocoder