Try this, you'd better run it in a separately thread rather than UI-thread. You can both get Address
and GeoPoint
by this method.
public static Address searchLocationByName(Context context, String locationName){
Geocoder geoCoder = new Geocoder(context, Locale.getDefault());
GeoPoint gp = null;
Address ad = null;
try {
List<Address> addresses = geoCoder.getFromLocationName(locationName, 1);
for(Address address : addresses){
gp = new GeoPoint((int)(address.getLatitude() * 1E6), (int)(address.getLongitude() * 1E6));
address.getAddressLine(1);
ad = address;
}
} catch (IOException e) {
e.printStackTrace();
}
return ad;
}