Yep, that's the idea :-) And i hasn't failed me yet, either :) In my app using AsyncTasks, i take great care to not construct instances of inner-classes that are AsyncTasks or that are the callbacks that the AsyncTasks' onPostExecute calls. This is to avoid implicit references to activities held by static/global objects.
All the AsyncTasks instances and the callback-classes are defined as static and hold at most a reference to the application-context. On Jun 9, 7:19 am, Mark Murphy <mmur...@commonsware.com> wrote: > Streets Of Boston wrote: > > Android guarantees that during a configuration change, no message will > > be posted to 'the' activity inbetween an onDestroy and an onCreate (i > > remember a post by Dianna about this). > > > This means that the result from the onPostExecute either arrives > > before the activity is destroyed or after it is created (during a > > configuration change). > > Another variation on the theme is to have the AsyncTask not be a regular > inner class, but a static inner class or public class. Then, have the > activity return the AsyncTask itself in > onRetainNonConfigurationInstance(). The activity associates itself with > the task via accessor methods, detaching from the task in > onRetainNonConfigurationInstance() and re-attaching itself in onCreate(). > > I need to give this code a greater workout, but it hasn't failed me yet. > > http://github.com/commonsguy/cw-android/tree/master/Rotation/Rotation... > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > Android Development Wiki:http://wiki.andmob.org -- 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