title: IntentService not firing
body: <p>My application synchronizes data with a remote database via web service calls.  I make these calls in an IntentService so they can run in the background (I call it SyncService).</p>
  
  <p>The code to launch my IntentService looks like so:</p>
  
  <pre><code>Intent intent = new Intent();
  intent.setClass(appContext, SyncService.class);
  
  // place additional values in intent
  intent.putExtra("data_type", SyncService.ITEM_TRACKING);
  intent.putExtra("user_id", intUserId);
  
  // call SyncService
  appContext.startService(intent);
  </code></pre>
  
  <p>This, normally, looks great.  However, one of my friends, who is also a user of my app, often tells me his data doesn't sync and get displayed on our website.  His device happened to be displaying the symptoms while I was around.  I plugged his device into my computer and here is what I found:</p>
  
  <ul>
  <li>The code to launch SyncService (ie: the code above) was hit.</li>
  <li>I had a breakpoint inside the onHandleIntent method of my IntentService and it <strong>never</strong> gets hit.</li>
  <li>I checked his device's list of running services and SyncService was there and running.  Interestingly, it had been running for about 20 minutes.  I was under the impression that IntentService killed itself when it was all out of Intents to process.</li>
  <li>I force stopped the SyncService (not the app) and, all of the sudden, onHandleIntent started getting hit over and over.  It was like all the Intents were queued up somewhere on the device and were just now getting thrown at the SyncService.</li>
  </ul>
  
  <p>Does anyone have any ideas as to what may be the problem?  Do you think it's an issue with my app?  With Android?</p>
  
  <p>Again, I am handing a message to Android saying, "Start this IntentService or send the message to the already running IntentService."  At that point, I have no control.  The message never gets to the IntentService.  Once I force quit the app, the messages get sent to the IntentService and it does its job.</p>
  
  <p>UPDATE:  I think this code is fine, but I'll put it up since a lot of you may want to see it.</p>
  
  <p>Every Intent that comes in to the IntentService has an Extra denoting what "type" of call is to me made (ie: do I call <em>this</em> web service or <em>that</em> web service, etc).  When an Intent comes in to the IntentService, I check the "type" and, if there is already an Intent in the queue for that type, I add an Extra to it called "skip" so, when it is reached, I don't execute the search (basically the IntentService can build up lots of Intents and it makes no sense to call <em>this</em> web service when <em>this</em> webservice was called 20 seconds ago).  It basically protects the app from spamming the website.</p>
  
  <p><strong>It is important to note that none of this code is hit anyway (once the problem starts occurring).  onStartCommand does not get called until the app is killed</strong></p>
  
  <pre><code>    @Override
      public int onStartCommand (Intent intent, int flags, int startId) {
          // here be dragons
          // overriding this method and adding your own code is dangerous. i've wrapped
          // my code in a try/catch because it is essential that the super method be called
          // every time this method is entered. any errors in my code should not prevent this
          // or the app will explode.
          try {
              if (flags == 0 &amp;&amp; intent != null &amp;&amp; intent.hasExtra("data_type")) {
                  Integer intDataType = intent.getExtras().getInt("data_type");
  
                      if (!mCurrentTypes.containsKey(intDataType)
                              || !mCurrentTypes.get(intDataType)) {
                          mCurrentTypes.put(intDataType, true);  // put this type in the list and move on
                      }
                      else {
                          intent.putExtra("skip", true);  // mark this Intent to be skipped
                      }
              }
          }
          catch (Exception e) {
              // Log.e("Error onStartCommand", "error: " + e);
          }
  
          return super.onStartCommand(intent, flags, startId);
      }
  
  
  private void processIntent(Intent intent) {
          // do stuff if no "skip" Extra
          mCurrentTypes.put(intDataType, false);
      }
  </code></pre>