Currently, I have a loader
@Override
public Loader<List<HomeMenuRowInfo>> onCreateLoader(int arg0, Bundle bundle) {
    return new HomeMenuRowInfosLoader(this.getSherlockActivity());
}
Sometimes, I need to ask the loader to reload again, due to content changes. I will do this.
this.getLoaderManager().getLoader(0).onContentChanged();
However, I would like to pass some additional bundle information to the onCreateLoader callback when the content changes. I realize by using onContentChanged, there is no way to do so.
The only way I can figure out is
this.getLoaderManager().restartLoader(0, bundle, this);
I was wondering, is there any major differences in Loader behavior, of using restartLoader instead of onContentChanged, besides the ability to pass in bundle?
I think, the major difference is that the restartLoader method destroys the old loader that has the same ID and starts a new one while the onContentChanged method either forces the loader to load (forceLoad) or simply sets a flag that indicates the content has changed while the loader was stopped. In the second case the 'owner' of the loader remains responsible for its (re)loading after the content has changed. I assume this is done automatically by the loaderManager as in the restartLoader case.
If you decide to use the restartLoader method you should keep in mind the destruction of the old loader and the possible implications for your application, like slow re-initializations and so on.
You can take a look at the methods documentation for more info - restartLoader and onContentChanged
Also note that the old loader is destroyed when the new one finishes its work
State diagram should help with understanding how to use API. First time I also spent a lot of minutes for making picture clear. Use my work!
Article: https://plus.google.com/117981280628062796190/posts/8b9RmQvxudb

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With