Activity 1:SelectBatchStep. RecyclerView populated with MySQL database data
Activity 2: DoneBy. Simple activity inserting new data in the database.
Activity 1 is reloaded after Activity 2 finishes in order to show the updated recyclerView item.
I am trying to save the scrolling position in a recyclerview activity 1. I start a new activity 2 but the scroll position is not recovered when I call back the recyclerview activity 1.
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
savedInstanceState.putInt(SCROLL,scrollpositionkeeper);
super.onSaveInstanceState(savedInstanceState);
Log.v(TAG,"scrollpositionsaved"+savedInstanceState);
}
Logcat shows the bundle Is saved and the scroll position is correctly saved when I start the new activity 2.
Activity 2 is started from the recycler adapter using com.daimajia.swipe.SwipeLayout library.
Activity 1 is recalled from activity 2 as follows:
Intent intent1 = new Intent(DoneBy.this, SelectBatchStep.class);
Activity 1 has the following:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
scrollrecovered = savedInstanceState.getInt(SCROLL);
}
else {
scrollrecovered=0;
}
Log.v(TAG,"scrollpositionrecovered"+savedInstanceState);
setContentView(R.layout.activity_select_batch_step);
Activity 1 comes to the front and logcat shows that the Bundle is null
Why is the saved bundle null?