Avoid IllegalStateExceptions

commitAllowingStateLoss should do this for us. As noted in the TODO there is probably a better
way, but now is not time.
This commit is contained in:
Tom Hennen 2015-06-06 14:22:26 -04:00
parent 47e09623a9
commit e903a13a55
1 changed files with 7 additions and 1 deletions

View File

@ -332,7 +332,13 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity
FragmentTransaction t = fragmentManager.beginTransaction(); FragmentTransaction t = fragmentManager.beginTransaction();
t.replace(R.id.main_view, fragment, "main"); t.replace(R.id.main_view, fragment, "main");
fragmentManager.popBackStack(); fragmentManager.popBackStack();
t.commit(); // TODO: we have to allow state loss here
// since this function can get called from an AsyncTask which
// could be finishing after our app has already committed state
// and is about to get shutdown. What we *should* do is
// not commit anything in an AsyncTask, but that's a bigger
// change than we want now.
t.commitAllowingStateLoss();
if (navAdapter != null) { if (navAdapter != null) {
navAdapter.notifyDataSetChanged(); navAdapter.notifyDataSetChanged();
} }