Saving bundle (activity A):
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putString("test", "value");
super.onSaveInstanceState(outState);
}
Navigating to activity B;
startActivity(new Intent(getBaseContext(), B.class));
Going back to activity A:
startActivity(new Intent(getBaseContext(), A.class));
Trying to load the value I wrote to bundle in activity A:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.d("MY", "saved instance is null"+ Boolean.toString(savedInstanceState == null));
}
Returns always savedInstanceState = null. What I'm missing here?
onRestoreInstanceState is never triggered when I return to main activity
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…