android上的位置问题

时间:2013-05-24 08:15:15

标签: android location

我在使用位置时遇到问题。一旦我尝试从一个位置获得lat和long,我的代码似乎就失败了。

        String locationProvider = LocationManager.GPS_PROVIDER;
    LocationManager locationManager; 
    Location lastKnownLocation;
    locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    Log.d(TAG, "manager made");
    lastKnownLocation = locationManager.getLastKnownLocation(locationProvider);
    Log.d(TAG, "location stored");
    double lat = lastKnownLocation.getLatitude();
    double lon = lastKnownLocation.getLongitude();
    Log.d(TAG, "Lat, Long got:" + lat + ", " + lon);
    distBetween(lat, lon);
    Log.d(TAG, "Distance calc complete");
    Intent intent = new Intent(this, ListBuilder.class);
    startActivity(intent);

当我尝试调用.getLatitude()和getLongitude()

时失败

想法为什么?我有互联网权限并访问好位置。

0 个答案:

没有答案