title: Android IntentService not completing task if App is closed
body: <p>I'm using an IntentService to saveData to a SQLDatabase &amp; upload data to Parse. The IntentService works fine if I keep the app running. It also executes propery if I minimise it(by pressing the home button). </p>
  
  <p>But if I press the navigation button and destory the app(the thing where the app screen scales down and you swipe it off); then the IntentService stops running(it doesnt even call onDestory).</p>
  
  <p>What I want is to have the service execute all the tasks; and destory itself. Hence, START_STICKY (Intent) is not required as I dont want it to run continuously in the background.  </p>
  
  <p><strong>Starting IntentService</strong></p>
  
  <pre><code>Intent intent_publishService = new Intent(getApplicationContext(), PublishService.class);
  
  Bundle basket_storyData = new Bundle();
  basket_storyData.putAll( packStoryData() );
  intent_publishService.putExtra(KEY_BASKET_STORY_DATA, basket_storyData);
  
  intent_publishService.putParcelableArrayListExtra(KEY_BASKET_IMAGE_DATA, (ArrayList&lt;? extends Parcelable&gt;) final_image_data);
  startService(intent_publishService);
  </code></pre>
  
  <p><strong>PublishService.class <em>(Snippet)</em></strong> </p>
  
  <pre><code>@Override
  protected void onHandleIntent(Intent intent)
  {
      Log.i(TAG, "ONHANDLEINTENT" );
  
      context = getApplicationContext();
  
      final String KEY_BASKET_IMAGE_DATA = "key_basket_image_data";
      final String KEY_BASKET_STORY_DATA = "key_basket_story_data";
      final String KEY_BASKET_EXTRA      = "key_basket_extra";
  
  
      ArrayList&lt;ImagesData&gt; _iDataSave = new ArrayList&lt;ImagesData&gt;();
      _iDataSave.addAll( (Collection&lt;? extends ImagesData&gt;) intent.getParcelableArrayListExtra(KEY_BASKET_IMAGE_DATA) );
  
      Log.i(TAG, "_iDataSize:" + Integer.toString(_iDataSave.size()) );
  
      //Get Bundle Values
      Bundle storyBundle = intent.getBundleExtra(KEY_BASKET_STORY_DATA);
  
      publishStory(storyBundle, _iDataSave);
  }
  </code></pre>
  
  <p><strong>Edit1: Manifest Declaration</strong>  </p>
  
  <pre><code>&lt;service android:name="com.example.create.main.PublishService" /&gt;
  </code></pre>
  
  <p><strong>SOLVED</strong></p>