I would like to notify ViewPagerAdapter that dataset changed in Loader.onLoadFinish callback function.
It is prevented because state of fragments might be saved.
From LoaderManager.LoaderCallbacks.onLoadFinished(Loader loader, D data) method documentation:
Note that normally an application is not allowed to commit fragment transactions while in this call, since it can happen after an activity’s state is saved.`
How can I overcome this problem? How can I check in which state Activity is and commit Fragment transaction?
I’ve come with following solution:
Method
changeCursorInOtherThreadis used inonLoadFinishedandonLoaderReset.Handleris created inActivity: