Well...  we guarantee that if your activity is in the foreground during a
configuration change, the main thread will perform the destruction of the
old activity and creation of the new activity without processing any
messages.  (Basically it receives an internal  message to update the config,
and the implementation of that does the complete series of callback and
bookkeeping for destroying the current activity and creating the new one.)
So if you were to say have a staticb that holds the current activity
instance, which is set in onCreate() (and probable cleared in onDestroy() if
referencing that instance), then no synchronization is needed: when your
async task completes, just get the current activity from the static, and use
that.  Of course you also want your async task to be static (if it is an
inner class) so it isn't holding any references to a possibly destroyed
activity.

On Mon, Oct 19, 2009 at 11:08 AM, Mark Murphy <[email protected]>wrote:

>
> szabolcs wrote:
> > Am I correct in assuming that any callbacks of the AsyncTask that are
> > run on the UI thread (e.g. onPostExecute) are 'queued' during a screen
> > rotation?
>
> No.
>
> > I assumed so, since looking at DDMS, it seems like the rotation does
> > NOT create a new UI thread, in which case any calls to the UI must be
> > stalled while the UI thread is busy completing the rotation, right?
>
> No.
>
> > It would be great if this was true, since it would save me from having
> > to do a bunch of synchronization work for posting back from AsyncTasks
> > (I am keeping the tasks running during a rotation) - at least so I
> > think..
>
> No there, too.
>
> If you wish to modify the UI, your AsyncTask needs access to the current
> activity. This may or may not be the instance of the activity that
> kicked off the AsyncTask.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://twitter.com/commonsguy
>
> _Beginning Android_ from Apress Now Available!
>
> >
>


-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~
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