Fixed potential crash during app start.

This commit is contained in:
Felix Ableitner 2014-05-04 11:58:43 +02:00
parent 65c5e0e793
commit 55bb705ac0

View file

@ -216,10 +216,13 @@ public class MainActivity extends ActionBarActivity {
@Override @Override
protected void onSaveInstanceState(Bundle outState) { protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
FragmentManager fm = getSupportFragmentManager(); // Avoid crash if called during startup.
fm.putFragment(outState, ServerFragment.class.getName(), mServerFragment); if (mServerFragment != null && mRouteFragment != null) {
fm.putFragment(outState, RouteFragment.class.getName(), mRouteFragment); FragmentManager fm = getSupportFragmentManager();
outState.putInt("currentTab", mViewPager.getCurrentItem()); fm.putFragment(outState, ServerFragment.class.getName(), mServerFragment);
fm.putFragment(outState, RouteFragment.class.getName(), mRouteFragment);
outState.putInt("currentTab", mViewPager.getCurrentItem());
}
} }
/** /**