-1

I am using Geocoder to get the lat and long in my android application. It was working fine some while back but now it just stopped working. I didn't change the code. Why this happned?

public void onItemClick(AdapterView adapterView, View view, int position, long id) {
        String str = (String) adapterView.getItemAtPosition(position);
    List<Address> addressList= null;
            if(str != null || str.equals("") ){
                Geocoder geocoder = new Geocoder(this);
                try {
                    addressList = geocoder.getFromLocationName(str, 1);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                Address address = addressList.get(0);
                //LatLng latLng = new LatLng(address.getLatitude(),address.getLongitude());
                Intent i = new Intent(Activity2.this, MainActivity.class);
                i.putExtra("location", str);
                i.putExtra("latitude", address.getLatitude());
                i.putExtra("longitude", address.getLongitude());
                startActivity(i);
            }
}

Thank you!!

S.Spieker
  • 7,005
  • 8
  • 44
  • 50

1 Answers1

0

Are you receiving IOException: Timed out waiting for response from server error? Because I've already seen other posts where it is mentioned that Geocoder isn't functioning properly, even though it did earlier (a few hours/days ago). I went to the public ticket - https://code.google.com/p/gmaps-api-issues/issues/detail?id=9153 - that was made when this happened last January, and it seems there are others who are experiencing this. You did mention you didn't modify anything in the code, right?

AL.
  • 36,815
  • 10
  • 142
  • 281