Java – Geocoder “Timed out waiting for response from server”

Geocoder “Timed out waiting for response from server”… here is a solution to the problem.

Geocoder “Timed out waiting for response from server”

I’m trying to convert latitude and longitude to addresses. When I used WIFI, I got the right answer. But when I try to use 3G/LTE, I get an error :

Timed out waiting for response from server.

I found this in Debug mode. But why? I use the same information (latitude, longitude). How do I fix it? This is my feature

public void convert_adresses (double lat , double lng) throws IOException
{
    addresses = geocoder.getFromLocation(lat, lng, 1);

address = addresses.get(0).getAddressLine(0);
    city = addresses.get(0).getAddressLine(1);
    country = addresses.get(0).getAddressLine(2);

txt_street.setText(address);
    txt_city.setText(city);
    txt_country.setText(country);

}

I call it like this:

try {
            convert_adresses(latitude,longtitude);
        } catch (IOException e) {
            e.printStackTrace();
}

Does anyone have an idea?

Solution

I’m not sure GEOcoding: maybe there’s something wrong with your network provider….

Try opening the following URL from your device and check if you get the desired output over your wifi connection

https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA

Related Problems and Solutions