我想基于long/lat得到一个地址.似乎这样的事情应该有效吗?
Geocoder myLocation = Geocoder(Locale.getDefault());
List myList = myLocation.getFromLocation(latPoint,lngPoint,1);
Run Code Online (Sandbox Code Playgroud)
问题是我不断得到:方法Geocoder(Locale)未定义类型savemaplocation
任何帮助都会有所帮助.谢谢.
谢谢,我尝试了上下文,首先是locale,然后失败并且正在查看其他一些构造函数(我曾经看过一个只提到locale).而不管,
它没有用,因为我仍然得到:方法Geocoder(Context,Locale)未定义类型savemaplocation
我有:import android.location.Geocoder;
最近,我创建了一个简单的应用程序来获取gps位置并在Android手机上显示.开始时,我可以在几次尝试后获取位置,但在重新安装apk文件后,getLastKnownLocation()始终返回空值.
使用的开发环境: - API 10姜饼2.3.6 - 使用GPS提供商
下面是我在我的android项目中应用的代码:
public class MyActivity extends MapActivity{
protected void onCreate(Bundle savedInstanceState) {
mapView = (MapView)findViewById(R.id.myTripMap);
mapController = mapView.getController();
mapView.setSatellite(false);
mapView.setStreetView(true);
mapView.displayZoomControls(false);
mapView.setBuiltInZoomControls(true);//
mapView.setClickable(true);
mapController.setZoom(14);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);
provider = locationManager.getBestProvider(criteria, true);
location = locationManager.getLastKnownLocation(provider);
updateMyCurrentLoc(location);
locationManager.requestLocationUpdates(provider, 2, 1,locationListener);
}
private final LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
updateMyCurrentLoc(location);
}
public void onProviderDisabled(String provider){
updateMyCurrentLoc(null);
}
public void onProviderEnabled(String provider){ }
public void …Run Code Online (Sandbox Code Playgroud)