AsyncTask.onCancelled() not being called after cancel(true)
<p>Android SDK v15 running on a 2.3.6 device.</p>

<p>I'm having an issue where onPostExecute is still being called when I am calling cancel within a doInBackground call.</p>

<p>Here is my code:</p>

<pre><code>@Override
public String doInBackground(String... params) {
    try {
        return someMethod();
    } catch (Exception e) {
        cancel(true);
    }

    return null;
}

public String someMethod() throws Exception {
    ...
}
</code></pre>

<p>I am forcing someMethod to throw an exception to test this out, and instead of onCancelled being called, I always return to onPostExecute. If I check isCancelled() the returned value is true, so I know that cancel(true) is being executed.</p>

<p>Any ideas?</p>
