Asynctaskloader: Onloadfinished Not Called After Orientation Change
I have a AsyncTaskLoader with a long running task, when, while the loader is running, my activity is being destroyed due to an orientation change, the onLoadFinished callback isn't
Solution 1:
During orientation change your Activity is destroyed and recreated, but the loaders are not.
It is worth noting, that a call to initLoader() does not necessarily starts another loader. If the loader adressed by the specific ID exists, it is reused by LoaderManager and your callbacks are reattached to it. So you can remove your (!loading) condition, and call initLoader in every onCreate() callback. Just make sure the loader's ID is the same.
See also Loader guide
Solution 2:
From the documentation, as long as the id is the same as the one you first passed it, it should return the current loader rather than a new one: android docs
Solution 3:
Adding android:configChanges="orientation|screenSize"
to my activity did the trick for me.
Post a Comment for "Asynctaskloader: Onloadfinished Not Called After Orientation Change"