title: Android AsyncTask won't stop when cancelled, why?
body: <p>I've an AsyncTask that I shut down in the Activity's onPause lifecycle event, so it doesn't run when someone leaves the app, but it keeps going despite this. I added some tracing and this snippet shows the problem. </p>
  
  <pre><code>    Trace.d(TAG,"Task state: " + myTask.getStatus() );
      myTask.cancel(true);
      Trace.d(TAG,"Task state: " + myTask.getStatus() );
  </code></pre>
  
  <p>Outputs:</p>
  
  <pre><code>Task state: RUNNING
  Task state: RUNNING
  </code></pre>
  
  <p>Why is the cancel() method not having any effect on the state of the task? I notice the docs say the cancel method will "attempt" to stop the task, but under what circumstances will it fail? The task is definitely running as it is outputting log output every ten seconds, and as you can see above its status is returned as running.</p>
  
  <p>Update: I added tracing to show me the isCancelled() state as well and that DOES change. So the call to cancel(true) is changing the cancelled state from false to true, but apparently having no effect on the Status, or stopping the thread.</p>