android - 不兼容的类型错误 Geocoder Google API

标签 android google-maps google-geocoder

我正在尝试在 Android 中使用谷歌的地理编码器 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> gclist ;
        gclist  = mygeocoder.getFromLocationName(inputaddress,1);

关于android - 不兼容的类型错误 Geocoder Google API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38448180/

相关文章:

android - 为什么 Android Geocoder 会抛出 "Service not Available"异常?

javascript - Google map /地点地理编码

java - Android Activity 上下文为空

java - TCP\IP 客户端 - EHOSTUNREACH(没有到主机的路由)

java - BitmapFactory.decodeStream 返回 null

java - 生成 map 标记

javascript - Uncaught ReferenceError : google is not defined

javascript - 谷歌地图信息窗口中的下拉菜单

android - 如何识别键盘上按下的空格

android - Places Autocomplete API 从输入的地址获取 GPS 坐标