I have the problem that if I try to get an address with the geocoder.getFromLocationName("California",1) function, it founds the address but if I test it on my device (Xiaomi Mi5, Oreo) it returns an empty list.
Thanks in advance!
private void geoLocate(){
Log.d(TAG, "geoLocate: geolocating");
String searchString = mSearchText.getText().toString();
Log.d(TAG, "geoLocate: Searching for " + searchString);
Geocoder geocoder = new Geocoder(this);
List<Address> list = new ArrayList<>();
try{
if(geocoder.isPresent()){
list = geocoder.getFromLocationName(searchString,1);
} else{
Log.d(TAG, "geoLocate: GEOCODER IS NOT PRESENT");
}
}catch (IOException e){
Log.e(TAG, "geoLocate: IOException " + e.getMessage() );
}
if(list.size() > 0 ){
Address address = list.get(0);
Log.d(TAG, "geoLocate: found a location: " + address.toString());
}else{
Log.d(TAG, "geoLocate: Location not found");
}
}