get Address String - Android Map

Android examples for Map:Address

Description

get Address String

Demo Code


//package com.java2s;
import android.location.Address;

public class Main {
    public static String getAddressString(Address address) {
        if (address.getMaxAddressLineIndex() == -1) {
            return null;
        }//w w w .j  a v  a2 s .c  o m
        StringBuilder addressStringBuilder = new StringBuilder();
        for (int i = 0; i <= address.getMaxAddressLineIndex(); i++) {
            addressStringBuilder.append(address.getAddressLine(i));
            if (i != address.getMaxAddressLineIndex()) {
                addressStringBuilder.append(", ");
            }
        }
        return addressStringBuilder.toString();
    }
}

Related Tutorials