I have a variable that I have successfully saved and restored using onSaveInstanceState
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); // the UI component values are saved here.
outState.putDouble("VALUE", liter);
Toast.makeText(this, "Activity state saved", Toast.LENGTH_LONG).show();
}
But this only works if the activity is destroyed. I want to save the same variable by overriding the onPause() method and getting back when the activity is not not paused anymore any ideas on how to do this are greatly appreciated
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…