在 Geocoder Android Studio 中验证 featureName 为 null 或为空地址中的数字

问题描述

我在使用 google place 的 android studio 中有一个地址搜索框,我需要验证用户输入的地址是否具有 Geocode 中的 featureName 或验证他是否已将街道号码放入地址. 问题在于,当您输入的地址没有 featureName 或地址中的数字时。地理编码,它认返回一个要素名称,所以我无法验证用户是否在地址中输入了要素名称或数字。

您知道如何进行此验证吗?

示例地址:

永生大道,斯普林菲尔德

Geocoder geocoder;
List<Address> direccion;
geocoder = new Geocoder(this,Locale.getDefault());

direccion = geocoder.getFromLocation(latitude,longitude,1); // 1 representa la cantidad de resultados a obtener

String address = direccion.get(0).getAddressLine(0); // If any additional address line present than only,check with max available address lines by getMaxAddressLineIndex()
String featureName = direccion.get(0).featureName();

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)