0

I'm trying to use reverse geocoding to view the location of specific coordinates. I'm using the following code.

Geocoder geoCoder = new Geocoder(getBaseContext(),Locale.getDefault());
    try {
        addresses = geoCoder.getFromLocation(dbllat, dbllong,1);
        if(addresses != null && addresses.size() > 0 ){
            Address address = addresses.get(0);
            addressText = String.format("%s, %s, %s",
                    address.getMaxAddressLineIndex() > 0 ? address.getAddressLine(0) : "",
                            address.getLocality(),
                            address.getCountryName());
        }
        Toast.makeText(getBaseContext(), addressText, Toast.LENGTH_SHORT).show();
    }
        catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Toast.makeText(getBaseContext(), "ERROR", Toast.LENGTH_SHORT).show();
    }

I always gets the "ERROR" Toast. what is the problem?

0 Answers0