Android Geocoder 只返回一个地址

标签 android

如果用户尝试在我的应用中查找地址,我将使用以下代码获取建议列表:

String locationName = "Berli"
if (Geocoder.isPresent()) {
    Geocoder geocoder = new Geocoder(getBaseContext(), Locale.getDefault());
    List<Address> list = geocoder.getFromLocationName(locationName, 5);
}

但它只返回“Berli, India”作为我列表中的单个条目 - 而不是其他可能的地址,如“Berlin, Germany”等。同样,当我尝试许多其他地方时,只显示一个建议。这是 Geocoder 的正确行为还是我应该使用其他解决方案?

非常感谢, 克里斯

最佳答案

听起来自动完成比地理编码更符合您的需求。

看看Place Autocomplete in the Google Places API .

关于Android Geocoder 只返回一个地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45398698/

相关文章:

java - Android:Resources.getSystem().getIdentifier 返回 java.lang.IllegalArgumentException

Android ImageButton 从屏幕上截断

android - 在后台更新位置?

java - Android : why does native_start fails in startNavigating() on Android 2. 3.1 模拟器?

Android 解析、通知和构建类型

android - Facebook FriendPickerFragment 显示没有 friend

android - 如何创建 2 级或 3 级可扩展 ListView?

android - 在 TextWatcher 中更改文本后未更新 EditText

android - 记得在所有 Realm 实例上调用 close() 但所有的东西都应该关闭

android - 模拟器上的错误 - Android Studio Chipmunk 2021.2.1 Canary 7