So I've tried many different solutions as found online and on StackOverflow but I just can't seem to get this to work. Here is what I am working with right now which I have from a similar post on SO. What am I doing wrong?
public void getLocationName() {
String strAdd = "";
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
try {
List<Address> addresses = geocoder.getFromLocation(49.123124, -122.652404, 1);
if (addresses != null) {
Address returnedAddress = addresses.get(0);
StringBuilder strReturnedAddress = new StringBuilder("");
for (int i = 0; i < returnedAddress.getMaxAddressLineIndex(); i++) {
strReturnedAddress.append(returnedAddress.getAddressLine(i)).append("\n");
}
strAdd = strReturnedAddress.toString();
Log.w("My Current loction address", "" + strReturnedAddress.toString());
} else {
Log.w("My Current loction address", "No Address returned!");
}
} catch (Exception e) {
e.printStackTrace();
Log.w("My Current loction address", "Cannot get Address!");
}
Toast.makeText(getApplicationContext(), "Distance between two locations is: " + strAdd.toString(), Toast.LENGTH_LONG).show();
}
It always throws the exception, so is it my coordinates?