private String getAddress() {
Geocoder geoCoder = new Geocoder(getBaseContext(), Locale.getDefault());
List<Address> addresses;
String location = "Cannot find user address";
String location = "Cannot find user address";
try {
addresses = geoCoder.getFromLocation(userPosition.getLatitudeE6() / 1E6,
userPosition.getLongitudeE6() / 1E6, 1);
if (addresses.size() > 0) {
location += addresses.get(0). getAddressLine(0) + ", " + addresses.get(0).getLocality() ;
}
return location;
} catch (IOException e) {
return location;
}
}
Así de simple. La variable "userPostion" es la posición actual del usuario.
it works!
Roger Sala,
No hay comentarios:
Publicar un comentario