@Override public void onBackPressed() { long curTime = System.currentTimeMillis(); if (curTime - lastTime < 1500) { super.onBackPressed(); FileUtil.saveFile(ContextUtil.getContext(), FileUtil.FILE_COMPANY, Company.getInstance()); } else { ContextUtil.toast("再按一次退出!"); lastTime = curTime; } }
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable("company", Company.getInstance()); }
@Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); Company.loadInstance((Company) savedInstanceState.getSerializable("company")); sendBroadcast(new Intent(LoginManager.ACTION_INVALIDATE)); }