1

I have the following Loader implemented, which is a subclass of AsyncTaskLoader. The LoaderManager initLoaderManager() is called in the Activity's onCreate() method.

When I rotate my screen, I see that the onLoadFinished() is getting called successfully, however I don't see any Loader lifecycle method (onStopLoading(), onStartLoading(), onReset()).

What is trigerring the onLoadFinished() method in this case? As per my understanding the onLoadFinished() is triggered by the Loader's deliverResult() method, which would be called after the loadInBackground() is done or we could call it in onStartLoading() to deliver the cached data to the Activity. In this case I don't see any state change happening for the Loader.

public EarthquakeLoader(Context context, String url) {
    super(context);
    this.mUrl = url;
}

@Override
public List<Earthquake> loadInBackground() {
    Log.e(LOG_TAG, "loadInBackGround()");
    List<Earthquake> earthquakes = QueryUtils.extractEarthquakes(this.mUrl);
    return earthquakes;
}

@Override
public void onStartLoading() {
    Log.e(LOG_TAG, "onStartLoading()");
    forceLoad();
}

@Override
public void onStopLoading() {
    super.onStopLoading();
    Log.e(LOG_TAG, "onStopLoading()");
}

public void onReset() {
    super.onReset();
    Log.e(LOG_TAG, "onReset()");
}
Reaz Murshed
  • 23,691
  • 13
  • 78
  • 98
Sumit Trehan
  • 3,985
  • 3
  • 27
  • 42

0 Answers0