我创建了两个活动 A 和 B。在活动 A 中,使用 onSaveInstanceState 方法我正在保存包值 ex(outState.putString("selectSaveDate", this.CalSelectedDate)) 并转到活动 B。当我点击返回按钮时Activity A ,在 oncreate 方法中,bundle 值为 null。我无法在 oncreate 方法中获取我保存的值。
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.clear();
Log.i("bundleSave", "tester1" + this.CalSelectedDate);
outState.putString("selectSaveDate", this.CalSelectedDate);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(savedInstanceState != null){
Log.i("todolist", "dsa" + savedInstanceState.getString("selectSaveDate"));
}
}