代码:
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
double longitude = location.getLongitude();
double latitude = location.getLatitude();
Geocoder gcd = new Geocoder(context, Locale.getDefault());
List<Address> addresses = **gcd.getFromLocation(latitude, longitude, 1);**
星号包括的那句代码出错了。谢谢
Geocoder gcd = new Geocoder(this, Locale.getDefault());
try {
List
Geocoder中的函数声明:
public java.util.List getFromLocation(double latitude, double longitude, int maxResults) throws java.io.IOException
你只需用try catch就行了。