Happo Happo - 1 month ago 21
Android Question

Restart Loader from other Fragment

I have a ViewPager with 3 Fragments in there. Each Fragment uses a AsyncTaskLoader to get there Data from a Database. Now i want to restart the loader of Fragment A from Fragment C but if i call

getLoaderManager.getLoader( "LOADER_A_ID" )


the result is null.
I read each LoaderManager has one Activity/Fragment and so has each Fragment a own LoaderManager.
Has anybody a good idea to solve my problem?

I would implement a GlobalLoaderManager which is a Singleton-Pattern and hold Fragment. The ViewPager reused his Fragments so i have only one instance of each Pager Fragment in this Manager.

Answer

The answer is the post from Luksprog. Thank you for your help.

I've made a small adjustment to some old code to show you how you might do what I said above. You can find it here gist.github.com/3511928 – Luksprog