4

I'm trying to convert the latitude and longitude to address. When I use the WIFI I'm getting the right answer. But when I try it with 3G/LTE I'm getting the error:

Timed out waiting for response from server.

I found this with the Debug Mode. But why? I'm using the same Information (Lat, Long). How can I fix it? Heres my Function

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);

}

And Im calling it like this :

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

Someone got a Idea ?

KishuDroid
  • 5,411
  • 4
  • 30
  • 47
Ahmet K
  • 713
  • 18
  • 42
  • Possible duplicate of [Geocoder.getFromLocation throws Exception](http://stackoverflow.com/questions/5222164/geocoder-getfromlocation-throws-exception) – surhidamatya Jan 05 '16 at 06:58
  • Look here for solution : http://stackoverflow.com/questions/23638067/geocoder-getfromlocation-function-throws-timed-out-waiting-for-server-response/36930800#36930800 – KishuDroid Apr 29 '16 at 06:16

3 Answers3

0

I'm not sure about GEOcoding.. May be problem is with ur network provider...

Try opening the following URL from the device and check whether ur getting the desired output as connected through wifi

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

pathfinder
  • 127
  • 4
  • 18
0

new Geocoder(context) -> You must give context's parameter an activity or uses base class of Activity's. don't use Context class instance.

The Goat
  • 1,080
  • 13
  • 19
0

I don't know how, but this solves problem addresses = geocoder.getFromLocation(lat, lng, 2);

Manikanta P
  • 2,777
  • 2
  • 19
  • 22