allows you to call them Fragment A and B. Fragment B is just a detailed view for A, which replaces fragment A with the click of a button in fragment A.
Replacement Code:
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_container, new DetailFragment());
transaction.addToBackStack(null);
transaction.commit();
When I now rotate the screen in fragment B once and click Back, the old fragment A is restored without any problems (it restores its state to onActivityCreated using the savedInstanceState package).
Now for the interesting part ...
When I rotate the screen in fragment B more than once and click Back, I get a NullPointerException because int[] data = savedInstanceState.getIntArray(STATE_DATA);in onActivityCreatedreturns null.
How can I fix this behavior? The only other way I was was through persistent storage (preference or DB), but this seems very inappropriate for use.
edit / additional information: the kit itself is not null, it is just empty
source
share