point to geo string - Android Map

Android examples for Map:Location String

Description

point to geo string

Demo Code


import java.io.IOException;
import java.util.List;
import java.util.Locale;
import com.android_mvc.framework.common.FWUtil;
import android.content.Context;
import android.location.Address;
import android.location.Geocoder;

public class Main{
    //from   ww w .  j a  v  a 2 s.co  m
    public static String point2geostr(double latitude, double longitude,
            Context context) {
        String address_string = new String();

        // ??????
        Geocoder coder = new Geocoder(context, Locale.JAPAN);
        try {
            List<Address> list_address = coder.getFromLocation(latitude,
                    longitude, 1);
            // may throw IOE

            if (!list_address.isEmpty()) {
                Address address = list_address.get(0);
                address_string = LocationUtil.address2geostr(address);
            }

            FWUtil.d("?????" + address_string);
            return address_string;
        } catch (IOException e) {
            return "?";
        }
    }
}

Related Tutorials