I eventually made my own best practices for AsyncTasks that survive
screen flips and can even maintain progress dialogs if needed, and
it's all very robust and reasonably clean - but it took a lot of
iteration and investigation.

Storing an AsyncTask is "not hard" if you understand what is
happening, but for people just getting into the Android system,
understanding that screen flips destroy Activity references and create
new ones is not trivial.  It's actually really confusing and setting
it all up right is pretty delicate.

At my workplace, I'm porting an Android app over to the Windows Phone
7 platform. Many things about WP7 development are new, some are
frustrating, but there's one notably easy thing about it, which is
this exact problem. Their WebClient class automatically handles
network calls in a background thread, and you can give it a lambda or
named function as a callback to run on the UI thread once it's done.
Survives screen flips just fine, no worries about it being killed. It
Just Works(tm).

I understand that Android is a very different system than WP/
Silverlight, with different considerations that elevate the complexity
of managing all the different fedeated components of an application -
but don't write off managing AsyncTasks as "not hard". It's very hard,
and other systems make it look glaringly so.

-- Eric

On Sep 10, 2:33 pm, Dimitris <[email protected]> wrote:
> Wow thank you, I've been finally waiting for some clarification
> regarding how safe it is when updating the instance of the Activity in
> a task.
>
> This should be well documented and perhaps an example should be
> provided.
>
> On Sep 10, 10:13 am, Mark Murphy <[email protected]> wrote:
>
>
>
> > On Fri, Sep 10, 2010 at 1:08 PM, Dianne Hackborn <[email protected]> 
> > wrote:
> > > 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().
>
> > Oh, that is absolutely fantastic to hear.
>
> > I'd think it should be documented either on that method or here:
>
> >http://developer.android.com/guide/topics/resources/runtime-changes.html
>
> > Thankyouthankyouthankyou! :-)
>
> > --
> > Mark Murphy (a Commons 
> > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> > Android Training in London:http://skillsmatter.com/go/os-mobile-server

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