JakeWharton/ActionBarSherlock — Issue #192: LoaderManager not restarted after orientation change
Author: hubermat
Created: 2012-01-17 12:12:47+00:00
State: open

After an orientation change, in FragmentActivity.onStart the newly created LoaderManager is not started again.
I did a fix and it works perfectly for me. Please find the changed code below:

```
/**
* Dispatch onStart() to all fragments. Ensure any created loaders are
* now started.
*/
@Override
protected void onStart() {
super.onStart();

mStopped = false;
mReallyStopped = false;
mHandler.removeMessages(MSG_REALLY_STOPPED);

if (!mCreated) {
mCreated = true;
mFragments.dispatchActivityCreated();
}

mFragments.noteStateNotSaved();
mFragments.execPendingActions();

if (!mLoadersStarted) {
mLoadersStarted = true;
if (mLoaderManager != null) {
mLoaderManager.doStart();
} else if (!mCheckedForLoaderManager) {
mLoaderManager = getLoaderManager(-1, mLoadersStarted, false);
// HUBERMAT: mLoaderManager is not started here!
// added fix to start the loader manager
if (mLoaderManager != null) {
if (!mLoaderManager.mStarted) {
mLoaderManager.doStart();
}
}
}
mCheckedForLoaderManager = true;
}
// NOTE: HC onStart goes here.

mFragments.dispatchStart();
if (mAllLoaderManagers != null) {
for (int i=mAllLoaderManagers.size()-1; i>=0; i--) {
LoaderManagerImpl lm = mAllLoaderManagers.valueAt(i);
lm.finishRetain();
lm.doReportStart();
}
}
}
```