如何从Android上的地址获取经度和纬度?

dio*_*dna 5 android google-maps

可能重复:
如何从地址中查找经度和纬度?

我想获得特定地址的纬度和经度。我怎样才能做到这一点 ?

Kam*_*mal 4

private void getFromLocation(String address)
    {
          double latitude= 0.0, longtitude= 0.0;

        Geocoder geoCoder = new Geocoder(this, Locale.getDefault());    
        try 
        {
            List<Address> addresses = geoCoder.getFromLocationName(address , 1);
            if (addresses.size() > 0) 
            {            
                GeoPoint p = new GeoPoint(
                        (int) (addresses.get(0).getLatitude() * 1E6), 
                        (int) (addresses.get(0).getLongitude() * 1E6));

                latitude=p.getLatitudeE6()/1E6;
                longtitude=p.getLongitudeE6()/1E6;


                }
        }
        catch(Exception ee)
        {

        }
    }
}
Run Code Online (Sandbox Code Playgroud)