I am creating an Android application and I need to use geolocation.
I started by using the Geocoder API with Android ( android.location.geocoder ), but it causes some problems (waiting for a response from the server), which seems common according to what I read.
To make the application work when this kind of error occurs, I use the Geocoding web service.
Now the application works every time. The problem is that the results returned by the geocoder from the API and the geocoder from the web service do not match.
For example, a web service returns only 3 addresses with only the city name and country, while geocoding from the API returns about 8 addresses with the function name, roadway, locale ...
Question: is there a way to make the web service results exactly the same as those specified in the API?
EDIT
Here is my MainGeocoder class:
public class MainGeocoder { private Geocoder geocoderAPI; private GeocoderRest geocoderRest; public MainGeocoder(Context context) { geocoderAPI = new Geocoder(context); geocoderRest = new GeocoderRest(context); } public List<Address> getFromLocationName(String search, int maxResults) { List<Address> addresses; try { addresses = geocoderAPI.getFromLocationName(search, maxResults); return addresses; } catch (IOException e) { e.printStackTrace(); try { addresses = geocoderRest.getFromLocationName(search, maxResults); return addresses; } catch (IOException e1) { return null; } catch (LimitExceededException e1) { return null; } } } }
It basically tries to get the address list from the API geocoding API. If an IO exception is thrown, it gets this list from the web service using the GeocoderRest class that was inserted here: https://stackoverflow.com/questions/932825/ ...
source share