On Sat, Oct 2, 2010 at 3:39 PM, Prakash Iyer <[email protected]> wrote:
> Each his own. Try writing a AsyncTask that say lives for more than 10s and > in the final result say updates a text field. Now before the AsyncTask > completes, just change the orientation. I'd bet most developers would assume > the text field will get updated. Most developers would be wrong as the > AsyncTask's onResult will be calling the original object's (the one that did > the execute) text field and not the one that is currently displayed. Can you > make sure this works? Yes! Should this be documented? I would think it is > absolutely essential. This has *nothing* to do with AsyncTask, this is all about the peculiarities of Activity. You will run into the same issue if you use HandlerThread, a raw Thread()... heck, you'd even have the issue if you didn't use another thread at all but just Handler.postDelayedMessage(). This behavior is documented in the material Activity; it doesn't make any sense to try to document this in every other generic facility for asynchronicity just because if you use that with an Activity you will need to understand how Activity instances can be fairly transient. And what you need to do with AsyncTask is *different* depending on where you are using it -- in an Activity, or a Service, or a View, or whatever. They each have their own sometimes subtle details about lifecycle that you need to understand when introducing asynchronicity. AsyncTask can't try to document exactly how to use it when combined with every other possible facility. -- 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

