A weak reference may not be collected by the time of onPostExecute,
even though that activity instance may have been destroyed
(orientation change, etc.).

The task would then, presumably, attempt to deliver the results and
update the UI of the old activity instance.

Really, a better way is to set the task to null in the owning
activity's onDestroy, and reset to the new one in onCreate in case it
was an orientation change. It's easy to know if it is by carrying the
currently running task over in the activity's
onRetainNonConfigurationInstance.

Of course if the app uses fragments, it easy enough to call
setRetainInstance(true) on the fragment, avoiding both issues.

-- K

2013/1/15 RichardC <[email protected]>:
> Conciser holding a WeakReference to the Activity from the AsyncTask.

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