I realize the OP has accepted the above answer but I have a feeling the OP wanted a more simple answer.
I am assuming the OP has an android application with an Activity. I declared mine like this:
public class HelloAndroidActivity extends Activity implements LocationListener {
The OP was confused as to how the lifecycle methods worked and when work should be done. My Resume and Pause methods would look like this:
@Override
protected void onPause() {
((LocationManager)getSystemService(Context.LOCATION_SERVICE)).removeUpdates(this);
super.onPause();
}
@Override
protected void onResume() {
((LocationManager)getSystemService(Context.LOCATION_SERVICE)).requestLocationUpdates(LocationManager.GPS_PROVIDER, 5 * 1000, 1, this);
super.onResume();
}
Notice that my onResume asks that I be notified when there are location updates and the onPause method asks that I no longer be notified. You should be careful to not ask for updates at a time interval smaller then you really need or you will drain your battery.
Since the activity implements LocationListener my onLocationChanged method looks like this:
@Override
public void onLocationChanged(Location location) {
// Update the location fields
((EditText)findViewById(R.id.latField)).setText(Double.toString(location.getLatitude()));
((EditText)findViewById(R.id.longField)).setText(Double.toString(location.getLongitude()));
}
This simply takes the new location and updates some text EditText fields that I have in my activity. The only other thing I needed to do was to add the GPS permission to my manifest:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
So if I were asking how to start out using the location manager and the location service this would be how I would begin. I'm not trying to take anything away from the accepted answer, I just think there was a fundamental misunderstanding about what to do in onResume and in the onLocationMethodChanged methods.