Android Address Get getLatLongFromAddress(String address)

Here you can find the source of getLatLongFromAddress(String address)

Description

This method used to get latitude-longitude from address.

Parameter

Parameter Description
address represented address

Return

represented

Declaration

public static Address getLatLongFromAddress(String address) 

Method Source Code

//package com.java2s;

import java.util.List;

import android.app.Activity;

import android.location.Address;
import android.location.Geocoder;

public class Main {
    public static Activity mSmartAndroidActivity;
    private static Geocoder geocoder;

    /**/*  ww w  .  j av  a 2 s  .  c om*/
     * This method used to get latitude-longitude from address.
     * 
     * @param address
     *            represented address
     * @return represented {@link Address}
     */
    public static Address getLatLongFromAddress(String address) {
        if (address != null && address.length() > 0) {
            geocoder = new Geocoder(mSmartAndroidActivity);

            List<Address> list = null;
            try {
                list = geocoder.getFromLocationName(address, 1);
                return list.get(0);
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }
        return null;

    }
}

Related

  1. isVictoriaAddress(Address address)
  2. getAddress(int contactId)