public static GeoPoint searchAddress(Context mContext,String mAddress)
{
GeoPoint mGeoPoint=null;
Geocoder coder = new Geocoder(mContext);
List<Address> address;
try
{
address = coder.getFromLocationName(mAddress,5);
if(address==null)
{
return null;
}
for(int i=0;i<1;i++)
{
Address location = address.get(i);
mGeoPoint=new GeoPoint((int)(location.getLatitude()*1E6), (int)(location.getLongitude()*1E6));
}
}
catch(Exception e)
{
return null;
}
return mGeoPoint;
}
Note:
Add Permission in Menifest.xml
<'uses-permission android:name="android.permission.INTERNET"/>
No comments:
Post a Comment