开发者

returning null when implementing Geocoder

I'm trying to find the address(location) using Geocoder.

I have the following code:

double lat = (double) (coord.getLat() * (1e-6));
double lon = (double) (coord.getLon() * (1e-6));
try { 
    List<Address> list = geocoder.getFromLocation(lat, lon,1);

    if (list != null && list.size() > 0) {
        Address address = list.get(0);
        result = address.getAddressLine(0) + ", "
            + address.getLocality();
    }
System.out.println("adresa returnata folosind geocoder:"
                + result);
}

The dat开发者_StackOverflowa that I pass to geocoder is in this format:

2.449548 48.950518

But when trying to println() the first address returned by Geocoder it returns null. This is how my logcat looks like:

reverseGeocode()`: no feature in GLocation

And my System.out.println() displays :null. I have internet acces and also internet permssion added to my manifest file. Does someone know what I'm doing wrong??


As Geobits said, your coordinates belong to place in the Arabian Sea. You cant get an Address from there, so your list is empty and your result is null.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜