I'm moving from activity 1 to activity 2 and send some data via intent . It's ok and no problem ,but when I leave activity 2 and then come back , the intent is empty . For solving this problem I've tried this code :
@Override
protected void onSaveInstanceState (Bundle outState) {
outState.putInt("row_id", row_id);
}
@Override
protected void onRestoreInstanceState (Bundle savedInstanceState) {
int row_idss = savedInstanceState.getInt("row_id");
Log.v("this","restore" + Integer.toString(row_idss));
}
I tried to save it before I leave the activity and retrieve it on re-open .anyway , It didn't work and didn't log it either.
I tried onPause and onResume , strangely they didn't call either . I used this code to make sure it runs
@Override
protected void onResume() {
super.onResume();
Log.v("this","test");
}
nothing logged . Could you help me to solve this problem ? I don't know what should I do to solve it
thanks so much
You are missing the calls:
super.onSaveInstanceState(outState);
super.onRestoreInstanceState(savedInstanceState);
Check the answer of this question, in this answer they're not using the method onRestoreInstanceState but just the onCreate to restore the data. You also could use onRestoreInstanceState if you need a different behaviour.