我有这个代码:
if (item.getItemId() == R.id.tempMap) {
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Location location = null;
if(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)||locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)){
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
provider = locationManager.getBestProvider(criteria, true);
location = locationManager.getLastKnownLocation(provider);
locationManager.requestLocationUpdates(provider, 20000, 1, this);
if (location != null) {
Log.e("PROVIDER SCELTO", provider);
onLocationChanged(location);
Log.e("LATITUDE", String.valueOf(latitude));
Log.e("LONGITUDE", String.valueOf(longitude));
和:
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
latitude = location.getLatitude();
longitude = location.getLongitude();
}
但它返回的最后一个 gps 点是我使用“谷歌地图导航器”后的最后一个点。所以,如果我不使用 gm navigator,则不会更新纬度和经度。
为什么???
谢谢