Re: [android-developers] onPostExecute and Activity State
On Sun, Jan 23, 2011 at 12:56 PM, Kostya Vasilyev <kmansoft@gmail.com> wrote:
> so your onPostExecute will get called as soon as
> doInBackground completes.
Not necessarily.
When doInBackground() completes, the background thread from the thread
pool sends a Message to a Handler, to cause onPostExecute() to be run
on the main application thread.
If the main application thread is not processing messages at this
time, then the onPostMessage() Message will be stuck in the queue
until such time as that state changes.
For example, during a configuration change, messages are not processed
on the old activity from onRetainNonConfigurationInstance() onward.
And, messages will not start up again until the new activity completes
onCreate(). This is how we can safely pass the AsyncTask from old to
new, and associate that task with the right activity, without
onPostExecute() being invoked during this transition.
I *think* that messages for an activity are not processed when it is
paused, but I'm not certain, as I haven't tried to test that specific
scenario, and I don't remember a particular Googly note on the
subject. Heck, the only reason I know what I wrote in the previous
paragraph is courtesy of a post on this list from Ms. Hackborn.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy
_Android Programming Tutorials_ Version 3.1 Available!
--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home