What i am doing ::
- I load a fragment(
eg:: Fragment-A
) to the container, and inonSaveInstanceState
event i am storing some data into bundle
i use the code
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("yourSpinner", spnSearchByCity.getSelectedItemPosition());
}
- Now i
replace
thecontainer
withFragment-B
on click of button inFragment-A
i use the code
fragment = FrgMdMap.newInstance(messengerObj);
if (fragment != null) {
getFragmentManager().beginTransaction().replace(R.id.content_frame, fragment).addToBackStack(null).commit();
}
I am successfully able to load the
Fragment-B
Now on orientation change of Fragment-B the
onSaveInstanceState
ofFragment-A
id firing
Questions::
- How is this taking place ?
- How can i make sure this wont happen ?