Android examples for android.location:Address
build Address string from Address
import android.location.Address; import java.util.ArrayList; import java.util.List; public class Main{ public static String buildAddress(final Address place) { List<String> parts = new ArrayList<>(); for (int i = place.getMaxAddressLineIndex(); i >= 0; i--) { parts.add(place.getAddressLine(i)); }/* ww w . jav a 2s .c o m*/ StringBuilder bldr = new StringBuilder(); for (String part : parts) { if (part != null && !StringUtils.isEmpty(part)) { if (bldr.length() > 0) { bldr.append(", "); } bldr.append(part); } } return bldr.toString(); } }