I have the following problem:
I wrote a function to determine the exact location of a street passed as a string parameter:
private GeoPoint LocationToGeoPointParser(String address) throws IOException
{
Geocoder geoCoder = new Geocoder(this.context,Locale.ENGLISH);
List<Address> addr = null;
addr = geoCoder.getFromLocationName(address, 1);
double la = addr.get(0).getLatitude();
double lo = addr.get(0).getLongitude();
Double longitude = addr.get(0).getLongitude()*1E6;
Double latitude = addr.get(0).getLatitude()*1E6;
return new GeoPoint(latitude.intValue(),longitude.intValue());
//return new GeoPoint(73,32);
}
If I use the function this way, when the map is loaded everything is working extremely slow. If i comment the geocoding code and use return new GeoPoint(73,32), it is working normally.
Can somebody explain me why geocoding slow my application down?
Thanks! 🙂
The Geocoder class requires a backend service that is not included in the core android framework. The Geocoder query methods will return an empty list if there no backend service in the platform.
Use the Thread like
HandlerorAsyncTasketc to will call background then change the UI