There is an interface called LocationListener:
http://developer.android.com/reference/android/location/LocationListener.html
You can use your LocationManager like:
public void startLocationUpdates() {
Criteria criteria = new Criteria();
String bestProvider = locationManager.getBestProvider(criteria, false);
locationManager.requestLocationUpdates(bestProvider, 60000, 10, new LocationListener() {
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {}
@Override
public void onProviderEnabled(String provider) {}
@Override
public void onProviderDisabled(String provider) {}
@Override
public void onLocationChanged(Location location) {
System.out.println("LOCATION CHANGED: "+location);
}
});
}
public void stopLocationUpdates() {
locationManager.removeUpdates(this);
}
The 10 is the minimum distance, and the 60000 in this case is the minimum time between requests.