Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.location.Address;
import java.util.List;

public class Main {
    public static String getAddressString(List<Address> addresses) {
        String locality = null;

        for (Address address : addresses) {
            String subLocality = address.getSubLocality();
            if (subLocality != null || locality == null) {
                locality = address.getLocality();
            }

            if (subLocality != null && locality != null) {
                return String.format("%s, %s", subLocality, locality);
            }
        }

        return locality;
    }
}