Doug,

AsyncTask doesn't know anything about Activity lifecycle (and can be used
with other app components).

As far as messaging goes, the UI thread continues to run and process
messages even if no activities are visible (there may be messages related to
services or app widgets, and also that's how your next activity is brought
onto the screen), so your onPostExecute will get called as soon as
doInBackground completes.

So - either cancel your task in onPause (beware that there was a thread race
issue, AFAIK fixed in 2.2), or set some kind of flag in the task object so
it doesn't try to update views that are no longer on the screen.

-- Kostya

2011/1/23 Doug Gordon <[email protected]>

> After the background thread of an AsyncTask has completed (i.e.,
> doInBackground returns), it is stated that onPostExecute runs "on the UI
> thread". Can I assume that if the activity has gone into the "paused" state
> or other non-active state, that onPostExecute will not be called until the
> activity has resumed (and is in the foreground)?
>
> It seems like it has to work this way, but I'm not sure exactly how the
> threading model works in Android.
>
>  Doug Gordon
>  GHCS Software
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

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

Reply via email to