I want to get a list of the 5 adresses more similar to the string passed, but something is not working.
For example, if I write "avenida" there are thousands of "avenida" streets in spain, but the method getFromLocationName returns 0.
private void getAddressInfo(Context context, String locationName){
Geocoder geocoder = new Geocoder(context);
try {
List<Address> a = geocoder.getFromLocationName(locationName, 5);
for(int i=0;i<a.size();i++){
String city = a.get(0).getLocality();
String country = a.get(0).getCountryName();
String address = a.get(0).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex()
addressList.add(address+", "+city+", "+country);
}
} catch (IOException e) {
e.printStackTrace();
}
}
Is there something wrong in the code?