According to http://developer.android.com/guide/components/loaders.html, one of the nice thing about loader is that, it is able to retain its data during configuration chang
I've had success subclassing AsyncTaskLoader and making a few tweaks to its methods.
public class FixedAsyncTaskLoader extends AsyncTaskLoader {
private D result;
public FixedAsyncTaskLoader(Context context) {
super(context);
}
@Override
protected void onStartLoading() {
if (result != null) {
deliverResult(result);
} else {
forceLoad();
}
}
@Override
public void deliverResult(T data) {
result = data;
if (isStarted()) {
super.deliverResult(result);
}
}
@Override
protected void onReset() {
super.onReset();
onStopLoading();
result = null;
}
@Override
protected void onStopLoading() {
cancelLoad();
}
}