title: Get GPS start/stop events with addGpsStatusListener
body: <p>In an application I would like to start a Service that can receive two
  notification from GPS: GPS_EVENT_STARTED and GPS_EVENT_STOPPED.</p>
  
  <p>To do so I've done the following code:</p>
  
  <pre><code>package com.test;
  
  import android.app.Service;
  import android.content.Context;
  import android.content.Intent;
  
  import android.location.GpsStatus;
  import android.location.LocationManager;
  import android.os.IBinder;
  import android.util.Log;
  
  public class TestNotification extends Service {
  
      private LocationManager mLm;
      private MyListener mMyListener;
  
      private class MyListener implements GpsStatus.Listener {
          @Override
          public void onGpsStatusChanged(int event) {
              Log.i("MyGps", "Event");
  
              switch(event) {
              case GpsStatus.GPS_EVENT_STARTED:
                  Log.i("MyGps", "Started");
                  break;
              case GpsStatus.GPS_EVENT_STOPPED:
                  Log.i("MyGps", "Stopped");
                  break;
              }
          }    
      }
  
      @Override
      public IBinder onBind(Intent arg0) {
          return null;
      }
  
      @Override
      public void onCreate() {
          mLm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
  
          mMyListener = new MyListener();
          mLm.addGpsStatusListener( mMyListener );
      }
  }
  </code></pre>
  
  <p>I also have set the following permission in manifest: ACCESS_FINE_LOCATION
  I don't want to use requestLocationUpdates because it makes the GPS working 
  everytime and send events when fixes change. </p>
  
  <p>It test it on emulator and on real device (Eclair) but it doesn't work,
  the Service never receive any notification.</p>
  
  <p>I've read in detail the following thread (<a href="https://stackoverflow.com/questions/2021176/android-gps-status">here</a>) but no solution work. 
  I send it in a separate question because I only want to be informed of 
  GPS start and stop, not fixes.</p>
  
  <p>Do you have any advice on this? 
  May be it is because I try to do it in a Service rather that in an Activity?</p>
  
  <p>Thanks for reading.</p>