【问题标题】:How to get persian address如何获得波斯地址
【发布时间】: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


    【解决方案1】:

    您有可能从getFromLocation 方法获得此信息,该方法返回了引用here 的空列表,但我通过以下操作解决了同样的问题。

    1. 如果您在这篇文章之前遇到过这个问题,请重新运行您的应用程序并查看 如果它现在可以工作。

    2. 如果仍然无法正常工作,请尝试卸载并删除所有文件 与 Android Studio 相关。 (不是项目文件)。

    3. 然后重新安装 Android Studio,然后重新打开项目备份。

    4. 运行应用时,使用不同的虚拟设备和设备 API。

    【讨论】:

      猜你喜欢
      • 2023-04-03
      • 2013-06-15
      • 1970-01-01
      • 2021-07-10
      • 2022-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多