11.09.2010 12:55, Indicator Veritatis пишет:
Option 4 certainly sounds like it will work, but it suggests some peculiar problems in the way the classes are designed. Service by definition is already in the background, it HAS no UI thread, so why do I need an AsyncTask there at all? The whole point of the latter is to communicate between UI thread and worker thread.
A Service runs on the UI thread by default, so some kind of mechanism to push work to a background thread is still required. It can be a WakefulIntentService, or, just as easily, an AsyncTask (I imagine it takes care of acquiring a wake lock).
It seems to me (and that's just my opinion) that onRetainNonConfigurationInstance / getLastNonConfigurationInstance is probably the easiest way for small, one-at-a-time async tasks, where UI feedback is supposed to be immediate.
These two methods use plain Java objects, don't require serialization or parceling, so they are a good fit. The only issue is - switching UI references. OnRetail... can null them out before storing the task in a configuration object, and onStart / getLast... can store new UI references in the task.
The task would also need to keep most recent progress state values, to be displayed in the newly created activity.
-- Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com -- 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

