title: Android Location Listener (or Android Events in general)
body: <p>I have a general question about LocationListener in Android. Perhaps this is about Android or Java events in general, but not sure. </p>
  
  <p>There seems to be a million ways to set up a LocationListener, and they all seem pretty ugly (mainly because of lack of reusability). Here is an example from android found <a href="http://developer.android.com/guide/topics/location/obtaining-user-location.html" rel="noreferrer">here</a>:</p>
  
  <pre><code>// 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);
  </code></pre>
  
  <p>This works, but, I'm really surprised that this is a standard way of writing OOP code...</p>
  
  <p>What I would really like to see is a simple a <em>reusable</em> way to implement LocationListener. Anybody know of a simple tutorial on how this could be done? My goal would be to be able to implement this easily any Activities that need to be updated with gps information... perhaps a Service? Thanks!</p>