title: Android: AsyncTask cancel() issues
body: <p>I have an EditText and an AsyncTask class. Whenever the text changes in the EditText, the AsyncTask class's object created and called execute() on it with the string. And the doBackground() is called which has only a single function which  in turn has multiple for loops one after another. A new object for AsyncTask is created whenever, the text changes. 
  When the text changes, the old Async object has to be cancelled and the new one should take control. But when I call cancel on the object, the old one continues to run and seems to call onPostExecute().
  Is there a way to avoid this. I mean, can I kill/(stop running) the old asyncTask object completely before running the new one?</p>
  
  <p><strong>EDIT</strong>
  This is my code,</p>
  
  <pre><code>if (getSuggestions1.getStatus() != AsyncTask.Status.RUNNING) {
      getSuggestions1.cancel(true);
      getSuggestions1 = new GetSuggestions1();
      getSuggestions1.execute(new String[] { str });
  }
  </code></pre>
  
  <p>As you can see I am calling execute() immediately after calling cancel on the same object. Also, as I said, I have multiple for loops(6). I am worried the function, the isCancelled(), returns true for one of the for loops as the object initialized immediately.</p>