But when i call initLoader() like it's done in the documentation, the UI-Thread is getting blocked with the code from onCreateLoader.
As Luksprog notes, onCreateLoader()
is called on the same thread that initLoader()
is called on, and usually that is the main application thread. The job of onCreateLoader()
to create the Loader
, as you might have guessed by the name.
Isn't that the whole point of Loaders?
The point of a Loader
is to load data. The point of an AsyncTaskLoader
is to load data asynchronously. You are welcome to create some other Loader
that does not inherit from AsyncTaskLoader
, in which case doing the loading asynchronously is your job.
what should i do to prevent the UI-Thread from beeing blocked here?
Write a correct implementation of onCreateLoader()
, one that creates a Loader
instance and returns it, rather than looping 100000000 times and then returning null
.
This is covered in the documentation on the Loader
framework.