summaryrefslogtreecommitdiffstats
path: root/core/java/android/os/AsyncTask.java
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2010-06-03 10:56:41 -0700
committerRomain Guy <romainguy@google.com>2010-06-03 10:56:41 -0700
commit4aaf8ec9dfb9a9e0f3d84e8ee95d7ac2ebca8d92 (patch)
tree8c6d610d5df545fe183dbff541e3a9e24500fcef /core/java/android/os/AsyncTask.java
parentd94e4c50b49e484b52dd673411cd0e770116eb86 (diff)
downloadframeworks_base-4aaf8ec9dfb9a9e0f3d84e8ee95d7ac2ebca8d92.zip
frameworks_base-4aaf8ec9dfb9a9e0f3d84e8ee95d7ac2ebca8d92.tar.gz
frameworks_base-4aaf8ec9dfb9a9e0f3d84e8ee95d7ac2ebca8d92.tar.bz2
Do not invoke onProgressUpdate if the task is canceled.
Bug #2734382 Change-Id: I8d507ae72af2f6dfe66598fb9090872520111a6b
Diffstat (limited to 'core/java/android/os/AsyncTask.java')
-rw-r--r--core/java/android/os/AsyncTask.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/core/java/android/os/AsyncTask.java b/core/java/android/os/AsyncTask.java
index e74697a..823134b 100644
--- a/core/java/android/os/AsyncTask.java
+++ b/core/java/android/os/AsyncTask.java
@@ -401,6 +401,9 @@ public abstract class AsyncTask<Params, Progress, Result> {
* publish updates on the UI thread while the background computation is
* still running. Each call to this method will trigger the execution of
* {@link #onProgressUpdate} on the UI thread.
+ *
+ * {@link #onProgressUpdate} will note be called if the task has been
+ * canceled.
*
* @param values The progress values to update the UI with.
*
@@ -408,8 +411,10 @@ public abstract class AsyncTask<Params, Progress, Result> {
* @see #doInBackground
*/
protected final void publishProgress(Progress... values) {
- sHandler.obtainMessage(MESSAGE_POST_PROGRESS,
- new AsyncTaskResult<Progress>(this, values)).sendToTarget();
+ if (!isCancelled()) {
+ sHandler.obtainMessage(MESSAGE_POST_PROGRESS,
+ new AsyncTaskResult<Progress>(this, values)).sendToTarget();
+ }
}
private void finish(Result result) {