0

I have a problem with Geocoder. I have done some research but i didn't find an answer to my problem.

This is my code:

public String getAddress(double lat,double lon){

 TextView tv=(TextView)findViewById(R.id.textView3);
 TextView tv2=(TextView)findViewById(R.id.textView4);

  tv.setText(lat+","+lon);///Checks did i received lat and lon (Yes)
  String ret = "";
  try {
      Geocoder geocoder = new Geocoder(this.getApplicationContext(), Locale.getDefault());
      List<Address>addresses = geocoder.getFromLocation(lat, lon, 1);
      if (addresses.isEmpty()) {
          ret = "No Address returned!";
      } else {
          ret = addresses.get(0).getCountryName() + ""+ >addresses.get(0).getFeatureName();
      }
  } catch (IOException e) {
      ret="We don't know your address...";
      e.printStackTrace();
  }

  return ret;
}

I tried to run my app on the emulator and my phone but it doesn't work. Every time it tells me "We don't know..."

I have permissions for INTERNET, ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION.

biddulph.r
  • 5,226
  • 3
  • 32
  • 47
MilanNz
  • 1,323
  • 3
  • 12
  • 29
  • Have you check in the logcat if there is some warnings related to this? – G.T. Jun 17 '14 at 15:52
  • if the device api level is less than jellybean then you might need to reboot the device http://stackoverflow.com/questions/15110528/service-not-available-while-calling-geocoder-getfromlocation – Illegal Argument Jun 17 '14 at 15:52
  • Could you post the stack trace from the IOException that is thrown? – biddulph.r Jun 17 '14 at 15:54
  • E/sw29 TextView(11517): getCurrentProcessName currProcessID=11517 , E/sw29 TextView(11517): currProcessName=com.rServices.home – MilanNz Jun 17 '14 at 15:56
  • thx , problem is solved! When i rebooted it work very good. thx :) – MilanNz Jun 17 '14 at 16:17

0 Answers0