Prevent Fragment recovery in Android

前端 未结 7 1748
星月不相逢
星月不相逢 2020-12-07 22:53

We are using Fragments and we don\'t need them to be automatically recovered when the Activity is recreated. But Android every time when Activity::onCreate(Bundle save

7条回答
  •  既然无缘
    2020-12-07 23:32

    I was having a problem with TransactionTooLargeException. So thankfully after using tolargetool I founded that the fragments (android:support:fragments) were been in memory, and the transaction became too large. So finally I did this, and it worked great.

    @Override
    public void onSaveInstanceState(final Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putSerializable("android:support:fragments", null);
    }
    

提交回复
热议问题