From 55bb705ac0f06f74557c783ff4c4714e60afba77 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sun, 4 May 2014 11:58:43 +0200 Subject: [PATCH] Fixed potential crash during app start. --- .../github/nutomic/controldlna/gui/MainActivity.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/com/github/nutomic/controldlna/gui/MainActivity.java b/src/com/github/nutomic/controldlna/gui/MainActivity.java index 7141730..ade41b9 100644 --- a/src/com/github/nutomic/controldlna/gui/MainActivity.java +++ b/src/com/github/nutomic/controldlna/gui/MainActivity.java @@ -216,10 +216,13 @@ public class MainActivity extends ActionBarActivity { @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - FragmentManager fm = getSupportFragmentManager(); - fm.putFragment(outState, ServerFragment.class.getName(), mServerFragment); - fm.putFragment(outState, RouteFragment.class.getName(), mRouteFragment); - outState.putInt("currentTab", mViewPager.getCurrentItem()); + // Avoid crash if called during startup. + if (mServerFragment != null && mRouteFragment != null) { + FragmentManager fm = getSupportFragmentManager(); + fm.putFragment(outState, ServerFragment.class.getName(), mServerFragment); + fm.putFragment(outState, RouteFragment.class.getName(), mRouteFragment); + outState.putInt("currentTab", mViewPager.getCurrentItem()); + } } /**