find Address from Location - Android android.location

Android examples for android.location:Address

Description

find Address from Location

Demo Code

import android.content.Context;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import java.io.IOException;
import java.util.List;
import java.util.Locale;

public class Main{

    public static List<Address> find(Location location, Context context) {
        Geocoder geocode = new Geocoder(context, Locale.getDefault());
        try {/*from   w w w  .j a v  a  2  s  .  c  o  m*/
            List<Address> address = geocode.getFromLocation(
                    location.getLatitude(), location.getLongitude(), 1);
            if (address.size() > 0) {
                return address;
            }
        } catch (IOException e) {
        }

        return null;
    }

}

Related Tutorials