find Location and return Address - Android Map

Android examples for Map:Address

Description

find Location and return Address

Demo Code


//package com.java2s;
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 {/*w w w  .j a  va  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