位置服务在模拟器中工作,但不在真正的Android设备上

时间:2012-09-01 20:23:37

标签: android

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

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;

}

而不是我发送地理位置修复:

geo fix -122.41914 37.77919

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

0 个答案:

没有答案