I've got a question regarding WeakReferences in Android. I'am using 
AndroidQuery in my app to load images asynchronous. I've modified the 
AndroidQuery source a bit, so that it is also able to send progress 
callbacks so that I can update the progressbars in my notifications. The 
problem is that the progress object in AndroidQuery is referenced as 
a WeakReference so that references to progressbars which are no longer 
visible on the UI are getting garbage collected. The problem now that 
AndroidQuery works with an ExecutorService and that my callback objects 
also are getting garbage collected when the Runnable has to wait for its 
execution. I could change the WeakReference to a hard one to fix this 
proboem, but then I would have memory leaks when referencing progressbars 
directly. Here is how I pass the callback interface to AndroidQuery:

aq.progress(new ProgressCallback() { 
@Override
public void setProgress(final int progress) {
 //update progressbar
}
 @Override
public void setMax(int max, int progress) {
 //update progressbar
}
})

Is there a way to pass such a callback object without loosing the reference 
when it is referenced inside an WeakReference object?

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to