0

I want get my location from a thread. I code as:

LocationManager locationManager;
            GeoPoint p;
            locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
            Criteria cri = new Criteria();
            String tower = locationManager.getBestProvider(cri, false);
            Location location = locationManager.getLastKnownLocation(tower);    

But How call requestLocationUpdates update location? Can you help me?

4

1 回答 1

1

您拥有开发者文档中的所有内容:请求位置更新

// Acquire a reference to the system Location Manager
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

// Define a listener that responds to location updates
LocationListener locationListener = new LocationListener() {
    public void onLocationChanged(Location location) {
      // Called when a new location is found by the network location provider.
      makeUseOfNewLocation(location);
    }

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

    public void onProviderEnabled(String provider) {}

    public void onProviderDisabled(String provider) {}
  };

// Register the listener with the Location Manager to receive location updates
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
于 2012-10-16T11:12:14.277 回答