I need to save some state when the user leaves my game during game play. Saving the state doesn't seem to be an issue, but I can't figure out how to restore it. The onCreate
function isn't called when the Activity
is resumed (only when it is first created), so I can't get my state back there. Logically, I would use onRestoreInstanceState
, but it isn't being called.
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
Log.d("RocketLaunch", "onRestoreInstanceState()");
savedState = savedInstanceState;
}
I see log output from onSaveInstanceState
, onResume
, onCreate
, etc, but I never see a log message from onRestoreInstanceState
and savedState
is always null. Why isn't onRestoreInstanceState
being called, and is there another way to get my state back?
Thanks!