When using a custom AsyncTaskLoader to load data from a web service, if I press the HOME button in the middle of the download process and run the application again, the onLoadFinished () method will not be called. My snippet calls setRetainInstance(true) in onActivityCreated() and also calls getLoaderManager.initLoader(0, null, this) in the same method (as recommended).
During testing, I see that when returning to the fragment, onActivityCreated() not called, so maybe therefore onLoadFinished() not called. But where else to put the initLoader() method? I read in several places that it cannot be called in onResume() .
So, any ideas? I have many downloaders on different screens of my application and I need to solve this problem in an elegant way.
android fragment
Catalin morosan
source share