LoaderCallbacks.onLoadFinished() is not called after load finishes
Asked Answered
F

1

3

I created a loader that descends from AsyncTaskLoader. It works 99% of the time, but there's an edge case where LoaderCallbacks.onLoadFinished() is not called after AsyncTaskLoader.loadInBackground() returns successfully. I don't know what's different in the edge case but I can't think of any reason why the loader would fail between these two calls. Is there anything I could be doing wrong?

Feld answered 14/7, 2015 at 17:37 Comment(2)
Take a look at this #7475256Freemasonry
Thanks but it didn't help. :-/Feld
F
0

First of all, it is important how you run your Loader:

You can run it first time by activity.getLoaderManager().initLoader() method, but you can't run it second time like this.

You need to use activity.getLoaderManager().restartLoader() method for further. You also can use this method right from the start, because it will init your loader if it was not initialized yet.

It is highly recommended to start loaders in Activity's onCreate method.

If you need to start your loader from somewhere else, and call to onLoadFinished does not happen (for example, after you rotate the screen), place call to getLoaderManager() in onCreate instead, it can really help.

Furr answered 17/6, 2018 at 6:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.