Hi Tobias

I don't know enough about your specific problem, but I can only tell you 
that the solution that I documented further up is in use in my production 
applications without problem. The main difference I guess is that I do all 
loader stuff inside the fragments (i.e. the initloader code is triggered 
typically from MyFragment.onCreate()).

maybe you provide a few more details which would make it easier to help.

cheers
- Rainer

On Sunday, January 11, 2015 at 5:28:44 PM UTC+1, Tobias Fuss wrote:
>
> Hello Rainer, 
> currently struggling with the same issue and already tried nearly every 
> possible solution out there (besides using the SupportLoaderManager)
> Your solution does not work in my case, after configuration change i still 
> get no onLoadFinished-callback and therefore the data-field stays empty. 
> .
> I'm using an activity with a single fragment that contains all the 
> loader-stuff in onActivityCreated (also tried this in other lifecycle 
> methods), any other solutions found in the meantime? (API 21, Lollipop)
> Thanks in advance
>
> Am Donnerstag, 4. Juli 2013 20:16:41 UTC+2 schrieb Rainer:
>>
>> Etienne, your solution is "nearly" correct. This is the working solution
>>
>> public static <T> void initLoader(final int loaderId, final Bundle args, 
>> final LoaderCallbacks<T> callbacks,
>>         final LoaderManager loaderManager) {
>>     final Loader<T> loader = loaderManager.getLoader(loaderId);
>>     if (loader != null && loader.isReset()) {
>>         loaderManager.restartLoader(loaderId, args, callbacks);
>>     } else {
>>         loaderManager.initLoader(loaderId, args, callbacks);
>>     }}
>>
>>
>> On Friday, July 27, 2012 12:00:17 AM UTC+2, Etienne wrote:
>>>
>>> Actually it should be:
>>>
>>> Loader loader = getLoaderManager().getLoader(-1);
>>>     if (loader != null && !loader.isReset()) {
>>>       getLoaderManager().restartLoader(-1, null, this);
>>>     } else {
>>>       getLoaderManager().initLoader(-1, null, this);
>>>     }
>>>
>>>
>>> You should only restart the loader if the loader is NOT reset.  So the 
>>> second condition in the if condition changes to the negated version.  I got 
>>> this to work for me.
>>>
>>>
>>> On Thursday, January 12, 2012 10:47:58 PM UTC-8, David Wu wrote:
>>>>
>>>> Hi there, 
>>>>
>>>> I ran into a very similar problem and solved it by replacing the 
>>>> following line in onActivityCreate() 
>>>>
>>>>     getLoaderManager().initLoader(0, getArguments(), this); 
>>>>
>>>> to 
>>>>
>>>>     Loader loader = getLoaderManager().getLoader(0); 
>>>>     if ( loader != null && loader.isReset() ) { 
>>>>         getLoaderManager().restartLoader(0, getArguments(), this); 
>>>>     } else { 
>>>>         getLoaderManager().initLoader(0, getArguments(), this); 
>>>>     } 
>>>>
>>>>
>>>> Not sure if it addresses your problem.  I hope it helps. 
>>>>
>>>>
>>>> On Dec 13 2011, 3:29 pm, kaciula <[email protected]> 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 athttps://
>>>> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to