geo string to address - Android Map

Android examples for Map:Address

Description

geo string to address

Demo Code


import java.io.IOException;
import java.util.List;
import java.util.Locale;

import android.content.Context;
import android.location.Address;
import android.location.Geocoder;

public class Main {

  public static Address geostr2address(String str_address, Context context) {
    Address address = null;// w  w w  .  j  a v  a  2  s.co m

    Geocoder coder = new Geocoder(context, Locale.JAPAN);
    try {
      List<Address> list_address = coder.getFromLocationName(str_address, 1);

      if (!list_address.isEmpty()) {

        address = list_address.get(0);

      }

      return address;
    } catch (IOException e) {
      return null;
    }
  }
}

Related Tutorials