-1

我正在尝试举例:http: //developer.android.com/training/basics/location/geocoding.html#TaskReverseGeocoding

有效,但实际上我得到了

服务不可用异常

当试图检索地址时,我已经通过了这个并获得了 API 密钥和所有这些东西,但没有任何改变,而且它甚至在设备本身上也不起作用!

4

1 回答 1

2
    Geocoder geoCoder = new Geocoder(getBaseContext(), Locale.getDefault()); 
    try {
        List<Address> addresses = geoCoder.getFromLocation(latitude, longitude, 1);
        if (addresses.size() > 0) {
            String address = "";
            for (int index = 0; index < addresses.get(0).getMaxAddressLineIndex(); index++)
                address += addresses.get(0).getAddressLine(index) + " ";
            tv.setText(address);                   Toast.makeText(getApplicationContext(),""+address,Toast.LENGTH_SHORT).show();
            Log.v("AddressTag", address);
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

于 2012-12-13T13:31:29.030 回答