Thanks a lot Mark, I will check all these things :)
On Tue, Sep 28, 2010 at 1:24 PM, Mark Murphy <[email protected]>wrote: > On Tue, Sep 28, 2010 at 7:14 AM, Jose Luis Montes <[email protected]> > wrote: > > What I do not understand is what do you want to mean with this: > >> > >> Due to possible activity configuration > >> > >> changes (e.g., orientation), it is probably better to have these tasks > >> > >> coordinated via a regular Service, but you could have an Activity > >> > >> manage its own if you are careful. > > > > Can you explain yourself a bit more?? > > There have been a few threads on this topic recently in this list. > > In a nutshell: > > -- Make sure your AsyncTask classes are not regular inner classes of > the activity. Either make them static inner classes or use > fully-separate classes. > > -- Manually associate your activity with the AsyncTask initially > (e.g., via its constructor). > > -- Return the AsyncTask object via onRetainNonConfigurationInstance(). > > -- In onCreate() of your Activity, check > getLastNonConfigurationInstance() and re-associate your activity with > any AsyncTasks in there (e.g., via a setter). > > Here is a sample project demonstrating this: > > http://github.com/commonsguy/cw-android/tree/master/Rotation/RotationAsync/ > > Android guarantees that no messages on the message queue will be > dispatched between onRetainNonConfigurationInstance() of your old > activity and onCreate() of your new activity. Hence, even if your > AsyncTask invokes publishProgress() or wraps up its doInBackground() > work, you are assured that your AsyncTask's onProgressUpdate() and > onPostExecute() methods will not be called while the configuration > change is happening. > > This adds a bit of complexity, which is why some people will be more > comfortable having a Service (or, conceivably, a custom Application > object) manage the AsyncTasks. > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://github.com/commonsguy > http://commonsware.com/blog | http://twitter.com/commonsguy > > Android Training in Atlanta: http://bignerdranch.com/classes/android > > -- > 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]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- 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

