From 6eab372680dab257104c189d22bd3f36c057e4e6 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 13 Dec 2013 01:18:05 +0100 Subject: [PATCH] Restore current tab if app was killed by system. --- src/com/github/nutomic/controldlna/gui/MainActivity.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/com/github/nutomic/controldlna/gui/MainActivity.java b/src/com/github/nutomic/controldlna/gui/MainActivity.java index 8fdfa5d..939b449 100644 --- a/src/com/github/nutomic/controldlna/gui/MainActivity.java +++ b/src/com/github/nutomic/controldlna/gui/MainActivity.java @@ -47,6 +47,7 @@ import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar.Tab; import android.support.v7.app.ActionBar.TabListener; import android.support.v7.app.ActionBarActivity; +import android.util.Log; import android.view.KeyEvent; import android.widget.CheckBox; import android.widget.CompoundButton; @@ -190,6 +191,7 @@ public class MainActivity extends ActionBarActivity { savedInstanceState, ServerFragment.class.getName()); mRouteFragment = (RouteFragment) fm.getFragment( savedInstanceState, RouteFragment.class.getName()); + mViewPager.setCurrentItem(savedInstanceState.getInt("currentTab")); } else { mServerFragment = new ServerFragment(); @@ -215,6 +217,7 @@ public class MainActivity extends ActionBarActivity { FragmentManager fm = getSupportFragmentManager(); fm.putFragment(outState, ServerFragment.class.getName(), mServerFragment); fm.putFragment(outState, RouteFragment.class.getName(), mRouteFragment); + outState.putInt("currentTab", mViewPager.getCurrentItem()); } /**