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.