我正在尝试制作示例:http://developer.android.com/training/basics/location/geocoding.html#TaskReverseGeocoding。
工作,但实际上我得到了
服务不可用例外
当试图检索地址时,我已经完成了这个并得到了API密钥和所有这些东西,但没有改变,它甚至在设备本身也不起作用!
答案 0 :(得分: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();
}
}