我目前正在使用 android 模拟器 2.3.3 。我想从坐标中获取位置。但我得到了这个“服务不可用”的例外。这是我的代码:
@Override
public boolean onTouchEvent(MotionEvent e, MapView mapView) {
if (e.getAction() == 1) {
GeoPoint point = mapView.getProjection().fromPixels(
(int) e.getX(), (int) e.getY());
Geocoder coder = new Geocoder(GoogleMaps.this, Locale.ENGLISH);
try {
List<Address> addresses = coder.getFromLocation(
point.getLatitudeE6() / 1E6,
point.getLongitudeE6() / 1E6, 1);
String address = "";
Address a = addresses.get(0);
Toast.makeText(GoogleMaps.this, a.getCountryName(), 300).show();
} catch (IOException e1) {
Toast.makeText(GoogleMaps.this, e1.getMessage(), Toast.LENGTH_LONG).show();
}
}
return false;