On Fri, Sep 10, 2010 at 10:04 AM, Mark Murphy <mmur...@commonsware.com>wrote:
> Worst-case scenario: > > Step #1: Take your UI setup that is in onCreate() and move it to a > separate method (e.g., setupViews()) > > Step #2: Call setupViews() from onCreate() > > Step #3: Call setupViews() from onConfigurationChanged() > > Done. ~4 lines of code. And it's the exact same code path that a > destroy/recreate will go down, so it's not like this adds unusual > performance overhead. There are certain circumstances where this may > not work (e.g., GLSurfaceView and a game), but you needed to do extra > work for those cases, anyway, to handle the destroy/recreate cycle. > Except if you are *relying* on this for your semantics then your code is not correct. > > Saving and restoring an AsyncTask is not difficult. > No, it's not. The question is: is it reliable? > Yes it is. If it isn't documented, I'll make sure it is: we guarantee that no messages will be processed between onRetainNonConfigurationInstance() to the following onCreate(). Option #4: Don't do the AsyncTask in an activity. Use a Service and > have it do the AsyncTask, or use an IntentService if the sole purpose > of the service is to do stuff in a background thread. In particular, > an IntentService would be good for a download that you want to happen > regardless of what may go on with an activity (e.g., Android Market > downloading an APK), and so you don't need to worry about canceling > it. > Yep in many cases this is actually what you want. -- Dianne Hackborn Android framework engineer hack...@android.com 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en