It will be ready to kill after onPostExecute() is called.

You can short-circuit this by calling cancel() from within your 
doInBackground() method then checking isCancelled() and if true stop 
whatever your doing and go straight to onPostExecute().

>From 
>AsyncTask<http://developer.android.com/reference/android/os/AsyncTask.html>
:
Cancelling a task

A task can be cancelled at any time by invoking 
cancel(boolean)<http://developer.android.com/reference/android/os/AsyncTask.html#cancel(boolean)>.
 
Invoking this method will cause subsequent calls to 
isCancelled()<http://developer.android.com/reference/android/os/AsyncTask.html#isCancelled()>
 to 
return true. After invoking this method, 
onCancelled(Object)<http://developer.android.com/reference/android/os/AsyncTask.html#onCancelled(Result)>,
 
instead 
ofonPostExecute(Object)<http://developer.android.com/reference/android/os/AsyncTask.html#onPostExecute(Result)>
 will 
be invoked after 
doInBackground(Object[])<http://developer.android.com/reference/android/os/AsyncTask.html#doInBackground(Params...)>
 returns. 
To ensure that a task is cancelled as quickly as possible, you should always 
check the return value of 
isCancelled()<http://developer.android.com/reference/android/os/AsyncTask.html#isCancelled()>
 periodically 
from 
doInBackground(Object[])<http://developer.android.com/reference/android/os/AsyncTask.html#doInBackground(Params...)>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to