Search code examples
androidandroid-fragmentsloaderandroid-loadermanager

Loader not retained and always created on orientation change


I have an Activity A that contains a Fragment B that contains a Fragment C.

Currently, Fragment B's LoaderManager manages one CursorLoader. The data is given to Fragment C.

On orientation change, the loader is lost: initLoader always leads to onCreateLoader being invoked by the system. However, the documentation says:

If the loader doesn't already exist, one is created and (if the activity/fragment is currently started) starts the loader. Otherwise the last created loader is re-used.

How do I get this behaviour?


Solution

  • It's an open bug, Google is aware and hopefully plan on fixing it

    https://code.google.com/p/android/issues/detail?id=183783