Restore current tab if app was killed by system.
This commit is contained in:
parent
90cec806ae
commit
6eab372680
1 changed files with 3 additions and 0 deletions
|
@ -47,6 +47,7 @@ import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.ActionBar.Tab;
|
import android.support.v7.app.ActionBar.Tab;
|
||||||
import android.support.v7.app.ActionBar.TabListener;
|
import android.support.v7.app.ActionBar.TabListener;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
|
@ -190,6 +191,7 @@ public class MainActivity extends ActionBarActivity {
|
||||||
savedInstanceState, ServerFragment.class.getName());
|
savedInstanceState, ServerFragment.class.getName());
|
||||||
mRouteFragment = (RouteFragment) fm.getFragment(
|
mRouteFragment = (RouteFragment) fm.getFragment(
|
||||||
savedInstanceState, RouteFragment.class.getName());
|
savedInstanceState, RouteFragment.class.getName());
|
||||||
|
mViewPager.setCurrentItem(savedInstanceState.getInt("currentTab"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mServerFragment = new ServerFragment();
|
mServerFragment = new ServerFragment();
|
||||||
|
@ -215,6 +217,7 @@ public class MainActivity extends ActionBarActivity {
|
||||||
FragmentManager fm = getSupportFragmentManager();
|
FragmentManager fm = getSupportFragmentManager();
|
||||||
fm.putFragment(outState, ServerFragment.class.getName(), mServerFragment);
|
fm.putFragment(outState, ServerFragment.class.getName(), mServerFragment);
|
||||||
fm.putFragment(outState, RouteFragment.class.getName(), mRouteFragment);
|
fm.putFragment(outState, RouteFragment.class.getName(), mRouteFragment);
|
||||||
|
outState.putInt("currentTab", mViewPager.getCurrentItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Reference in a new issue