Sunday, October 9, 2011

[android-developers] Re: Scenario where initLoader() does not call onLoadFinished()

I have the same issue. It looks like the bug in CurorLoader. Any ideas
of workaround fix for that?

On Oct 8, 12:29 am, kaciula <catalin.moro...@gmail.com> wrote:
> I have a simple activity with one fragment. The fragment uses a CursorLoader
> to load some data from a ContentProvider. I just call initLoader() inside
> onActivityCreated() and I populate the UI in onLoadFinished(). If I switch
> orientations, everything works as expected (onLoadFinished() is called
> again).
>
> Now, if I move to a new activity, press BACK to get back to my first
> activity and then switch orientations, I see that onLoaderReset() is called
> and then, in onActivityCreated(), although initLoader() is called,
> onLoadFinished() is never called after that. And as a consequence, my UI
> shows no data.
>
> After doing some testing, I see that this problem appears only if I use
> setRetainInstance(true) in my fragment. So what's the deal? And how can I
> fix this without removing setRetainInstance(true)? Do I have to do something
> in onLoaderReset()? Do I have to somehow give the loader the new activity as
> the context?
>
> Thanks.

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