public void setLocation(Location loc) { //Obtener la direcci—n de la calle a partir de la latitud y la longitud if (loc.getLatitude() != 0.0 && loc.getLongitude() != 0.0) { try { Geocoder geocoder = new Geocoder(this, Locale.getDefault()); List<Address> list = geocoder.getFromLocation(loc.getLatitude(),loc.getLongitude(), 1); if (!list.isEmpty()) { Address address = list.get(0); Toast.makeText(getBaseContext(), "Mi dirección es: \n" + address.getAddressLine(0), Toast.LENGTH_LONG).show(); } } catch (IOException e) { e.printStackTrace(); } } } |