Friday, June 18, 2010

[android-developers] Re: Avoid non-static inner classes in an activity?

On Jun 18, 6:56 am, Streets Of Boston <flyingdutc...@gmail.com> wrote:
> Stopping a thread does not necessarily garbage collect them...
>
> Put your references to your background threads/async-tasks inside an
> object that you pass back with onRetainNonConfigurationInstance and
> call getLastNonConfigurationInstance in your onCreate().
>
> If the android getLastNonConfiguration returns the object (the object
> you returned in onRetainNonConfigurationInstance), get the references
> to your background threads and assign the current activity to these
> threads where it is necessary.
>

It isn't being called in this case - since I'm handling configuration
changes for orientation - but there certainly could be cases where
this is useful.

> In the onDestroy(), get the references to your background threads and
> assign 'null' to the parts where references to your activity can be
> held.
>
I'm trying this.

> BTW: I think that a Handler() does not hold a reference to an activity-
> context.
>

This handler has an event listener inside a View, so for practical
purposes, it is holding a context. I'll be nulling it out on destroy.

Nathan

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment