0

我在我的项目中使用 HERE 地图。我无法获取用户的当前位置。但我可以得到最后一个已知的位置。

    mLocationManagerGPS = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

    mLocationListenerGPS = new LocationListener() {
        public void onLocationChanged(Location location) {
            System.out.println("GPS Position;");
            System.out.println(location.getLatitude());
        }

        public void onStatusChanged(String provider, int status, Bundle extras) {
        }

        public void onProviderEnabled(String provider) {
        }

        public void onProviderDisabled(String provider) {

        }
    };


    mLocationManagerGPS.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, 
    mLocationListenerGPS);


    //Working
    Location loc = mLocationManagerGPS.getLastKnownLocation(provider);
    System.out.println("GPS: " + loc.getLatitude());

mLocationManagerNetwork.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 5, 0, mLocationListenerNetwork); 正在工作,为什么我遇到上述问题?

4

0 回答 0