Re: [android-developers] Re: Scenario where initLoader() does not call onLoadFinished()
Until this is fixed (even without setRetainInstance()), my temporary workaround is:
Put the following into a subclass of the AsyncTaskLoader:
public static final SparseArray<Object> loaderResults = new SparseArray<Object>();
...
public void deliverResult(Object data) {
loaderResults.put(getId(), data);
}
...
@Override
public void onStart() {
super.onStart();
// Get any results that were not sent due to a bug with loaders
// and send them manually
SparseArray<Object> rArray = AbstractTaskLoader.loaderResults;
for (int i = 0; i < rArray.size(); ++i) {
int loaderId = rArray.keyAt(i);
// any code that you put in onLoadFinished() here, i.e. dismissing dialog
rArray.removeAt(i);
}
}
And also in onLoadFinished() don't forget to delete() that loader's key from this sparse array to prevent unneeded memory from being GCed.
Hope this helps someone.
Hi, we'll look at this issue, but I would generally recommend -- don't use setRetainInstance() with loaders. It is kind-of weird to do that. One of the big points of loaders is to take care of propagating state across activity/fragment instances, so there is no need to retain the instance.
On Mon, Dec 12, 2011 at 11:29 PM, kaciula <catalin.morosan@gmail.com> wrote:As I said, the initial bugs were fixed by revision 4 of ACL. However, there is still a bug present in both the ACL and Android. I've tested it with Android version 3.2 and 4.0. Check out the updated project at https://github.com/kaciula/BugRetain I think this is a pretty important bug. The scenario is this: From activity A, go to activity B, switch once the orientation and go back to activity A. As a consequence of this bug, I can't write an app with fragments that use setRetainInstance and is available in both orientations. I really need a workaround until the Android guys fix the issue. Thoughts?--
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 --
Dianne Hackborn
Android framework engineer
hackbod@android.com
Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them.
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
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home