Received: by 10.101.22.1 with SMTP id z1mr492259ani.4.1318268914953; Mon, 10 Oct 2011 10:48:34 -0700 (PDT) X-BeenThere: android-developers@googlegroups.com Received: by 10.101.163.13 with SMTP id q13ls12225078ano.0.gmail; Mon, 10 Oct 2011 10:47:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.101.23.16 with SMTP id a16mr1229412anj.3.1318268824489; Mon, 10 Oct 2011 10:47:04 -0700 (PDT) Received: by r8g2000prh.googlegroups.com with HTTP; Mon, 10 Oct 2011 10:47:04 -0700 (PDT) Date: Mon, 10 Oct 2011 10:47:04 -0700 (PDT) In-Reply-To: <7619709.586.1317994154884.JavaMail.geo-discussion-forums@yqmn40> References: <7619709.586.1317994154884.JavaMail.geo-discussion-forums@yqmn40> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET4.0C; .NET CLR 3.5.30729),gzip(gfe) Message-ID: <2c052262-2c78-432a-ac62-510260328e37@r8g2000prh.googlegroups.com> Subject: Re: Scenario where initLoader() does not call onLoadFinished() From: Jeremy Drake To: Android Developers Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable This sounds suspiciously like the issue I am having http://groups.google.com/group/android-developers/browse_thread/thread/ca3a= 0c174d284263 I was able to reproduce the bug with pushing a new activity in my own app, which uses an AsyncTaskLoader instead of a CursorLoader. Hopefully somebody familiar with the Fragment/FragmentManager/Loader/ LoaderManager code will reply to one (or both) of these threads with some additional insight. I'm planning to enter a bug/issue in the next day or two if I do not hear anything to the contrary. You may want to try setting a breakpoint around the time you call initLoader, and see if the LoaderManager's mDestroyed member is true. This is what led me to believe that the issue is with the lifetime management of the loader manager. On Oct 7, 6:29=A0am, kaciula wrote: > I have a simple activity with one fragment. The fragment uses a CursorLoa= der > to load some data from a ContentProvider. I just call initLoader() inside > onActivityCreated() and I populate the UI in onLoadFinished(). If I switc= h > 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 call= ed > 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 someth= ing > in onLoaderReset()? Do I have to somehow give the loader the new activity= as > the context? >