Android Loaders lifecycle, or: will onStopLoading () always be called before onReset ()?

Could there be a case in which onReset() is called without calling onStopLoading() immediately before it?

More generally, I'm trying to figure out the Loader life cycle, a-la activity life cycle graph and which onSomething() to run inside that state (s) of the activity life cycle / activity fragment.

+4
source share
1 answer

Yes, onReset() can be called without a previous call to onStopLoading() . The onStopLoading() implementation should ensure that no loads are started after that, while the onReset() implementation must do this and free up resources if they are not already released. onStartLoading() should be able to start / resume from both states.

Therefore, it seems good practice to call onStopLoading() in the onReset() implementation, as an example of code on the AsyncTaskLoader page.

+1
source

All Articles