0

我想获取用户的位置,所以我有这个代码:

LocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        // Register the listener with the Location Manager to receive location updates
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MINIMUM_TIME_BETWEEN_UPDATES,
                MINIMUM_DISTANCE_CHANGE_FOR_UPDATES, this);

        Log.d("locationManager ", "locationManager ");

        /*
         * try to get last know location
         */
        Location location = locationManager
                .getLastKnownLocation(LocationManager.GPS_PROVIDER);

public void onLocationChanged(Location location) {
    this.location=location;

}

然后我发送 geot fix:

geo fix -122.41914 37.77919

它在模拟器中运行良好,但是当我在真实设备上尝试时。它不起作用,我看到设备上的 GPS 图标闪烁。注意:设备上启用了 GPS。

4

0 回答 0