title: Using LocationManager in an IntentService doesn't seem to work
body: <p>I'm having an problem using LocationManager in my IntentService.  I'm developing an application to display a Map Image.  I want an IntentService to run the background to detect location changes.  When location updates are detected, the service will write the new location to the SQLite database.  The IntentService will send a Broadcast to the main Activity to let it know a new location has been stored.  The main app extracts the location for the database and moves the icon to the new location on the map.</p>
  
  <p>Here is the code for the Service:</p>
  
  <pre><code>import java.util.List;
  import java.io.*;
  
  import android.os.AsyncTask;
  import android.os.Bundle;
  
  import android.app.IntentService;
  import android.content.Context;
  import android.content.Intent;
  
  import android.widget.Toast;
  
  import android.location.GpsStatus;
  import android.location.Location;
  import android.location.LocationListener;
  import android.location.GpsStatus.NmeaListener;
  
  import android.location.LocationManager;
  
  import android.database.*;
  
  import android.util.Log;
  
  // local imports
  import com.saic.MCAppActivity;
  import com.saic.db.*;
  
  public class SaService extends IntentService {
  
      private static final String tag = "SaService";
  
  
      private Location loc = null;
      private Intent updateMapIntent = null;
      private LocationManager locMgr = null; 
      private boolean gps_provider = false;
      private boolean net_provider = false;
  
      public SaService ()
      {
         super( tag );
      }
  
      public SaService(String name)
      {
         super(name);
      }
  
      @Override
      protected void onHandleIntent(Intent intent)
      {
         updateMapIntent = new Intent();
         updateMapIntent.setAction( "UPDATE_LOCATION" );
  
         locMgr = MCAppActivity.getLocationManager();
  
         locMgr.requestLocationUpdates( LocationManager.GPS_PROVIDER, 60, 0,
                                        locationListener );
         locMgr.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, 60, 0,
                                        locationListener );
  
         // loop until told to quit
         while ( !MCAppActivity.toQuit() )
         {
            try {
               Thread.sleep( 30000 );
            }
            catch ( InterruptedException e ) {}
            getBaseContext().sendBroadcast( updateMapIntent );
         }
         stopSelf();
      }
  
  
      LocationListener locationListener = new LocationListener() {
          public void onLocationChanged(Location location) {
              double lat = 0.0;
              double lon = 0.0;
  
              // Called when a new location is found by the network location provider.
              if ( location.getProvider().equals(LocationManager.GPS_PROVIDER) )
              {
                 lat = location.getLatitude();
                 lon = location.getLongitude();
                 Log.i(tag, "LocationListener(): gps_provider location update:\nlat: " + lat +
                                                 "\nlon: " + lon );
                 writeLocationToDB( location );
              }
              else if ( location.getProvider().equals(LocationManager.NETWORK_PROVIDER) )
              {
                 lat = location.getLatitude();
                 lon = location.getLongitude();
                 Log.i(tag, "LocationListener(): net_provider location update:\nlat: " + lat +
                         "\nlon: " + lon );
                 writeLocationToDB( location );
              }
              else
              {
                 Log.i(tag, "LocationListener(): unknown provider found" );
              }
          }
  
          // don't need them now. make them NO-OP
          public void onStatusChanged ( String provider, int status, Bundle extras ) {}
          public void onProviderEnabled ( String provider )
          {
             Log.i( tag, "enable gps: "+ provider );
          }
          public void onProviderDisabled ( String provider )
          {
             Log.w( tag, "disable gps: "+ provider );
          }
  
      };
  
  }
  </code></pre>
  
  <p>The LocationManager is defined in my MCAppActivity and passed to the Service.  I get no errors when running the application on my phone.  However, the listener is never invoked. Is there a problem with invoking the LocationManager in a Service as opposed to an Activity? I do know I have to change the minTime to something larger to avoid battery drain. For now, I just want to see if I can get it to work.</p>
  
  <p>Thanks in advance.</p>