I have a AsyncTaskLoader
with a long running task, when, while the loader is running, my activity is being destroyed due to an orientation change, the onLoadFinished
callback isn't called.
Can I somehow 'reattach' the loader to my new Activity / it's callback?
Here's my (simplified) Activity:
public class DashboardActivity extends BaseActivity {
StartupCallback startupCallback;
boolean loading = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.empty_viewpager);
startupCallback = new StartupCallback();
if (!loading){
getSupportLoaderManager().initLoader(GlobalApp.giveId(), null,
startupCallback);
loading = true;
}
}
private class StartupCallback implements
LoaderManager.LoaderCallbacks<Boolean> {
@Override
public void onLoadFinished(Loader<Boolean> loader, Boolean succ) {
Log.d("LOG", "onLoadFinished");
}
@Override
public Loader<Boolean> onCreateLoader(int id, Bundle args) {
return new StartupLoader(getApplicationContext());
}
@Override
public void onLoaderReset(Loader<Boolean> loader) {
}
}
}
I can not just start another loader with a new callback because the loader does database stuff and two loader working on the same database will crash the app.