@Override public void onRestart() { super.onRestart(); SharedPreferences prefs = getSharedPreferences(Constants.Keys.SPF_GAME_STATE, Context.MODE_PRIVATE); long time = prefs.getLong(Constants.Keys.TIME, 0l); mElapsedTime = time; initTimer(); }
@Override public void onStop() { super.onStop(); mTimeHandler.removeCallbacksAndMessages(null); mTimeHandler = null; SharedPreferences prefs = getSharedPreferences(Constants.Keys.SPF_GAME_STATE, Context.MODE_PRIVATE); prefs.edit().putLong(Constants.Keys.TIME, mElapsedTime).commit(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState, R.layout.activity_race, R.color.WHITE); initGameView(new Game()); mScoreTv = (TextView) findViewById(R.id.score); updateScore(); initTimer(); mTarget = getIntent().getExtras().getInt(Constants.Keys.TARGET); initHighScore(); }