【问题标题】:Incompatible type error Geocoder Google API不兼容的类型错误 Geocoder Google API
【发布时间】:2016-07-19 01:22:07
【问题描述】:

我正在尝试在 Android 中使用 google 的 geocoder API。

代码如下:

 private void getLatLong(String inputaddress) throws IOException {
        Geocoder mygeocoder = new Geocoder(this.getContext());
        List<Address> gclist = mygeocoder.getFromLocationName(inputaddress,1);
    }

但是,我收到一个错误:

Error: incompatible types: List<android.location.Address> cannot be converted to List<com.google.android.gms.identity.intents.Address>

在声明列表时,我确保它是从 com.google.android.gms.identity.intents.Address 导入的,但我仍然收到此错误。 知道我哪里错了吗? 谢谢。

【问题讨论】:

  • 您的 List 声明是一个 android.location.Address 类型。尝试将其更改为 com.google.android.gms.identity.intents.Address

标签: android google-maps google-geocoder


【解决方案1】:

这成功了

List<android.location.Address> gclist ;
        gclist  = mygeocoder.getFromLocationName(inputaddress,1);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-23
    • 2011-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-14
    • 2012-10-19
    相关资源
    最近更新 更多