fragment/src/main/java/androidx/fragment/app/FragmentActivity.java
@Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        markFragmentsCreated();
        Parcelable p = mFragments.saveAllState();
        if (p != null) {
            outState.putParcelable(FRAGMENTS_TAG, p);
        }
        if (mPendingFragmentActivityResults.size() > 0) {
            outState.putInt(NEXT_CANDIDATE_REQUEST_INDEX_TAG, mNextCandidateRequestIndex);

            int[] requestCodes = new int[mPendingFragmentActivityResults.size()];
            String[] fragmentWhos = new String[mPendingFragmentActivityResults.size()];
            for (int i = 0; i < mPendingFragmentActivityResults.size(); i++) {
                requestCodes[i] = mPendingFragmentActivityResults.keyAt(i);
                fragmentWhos[i] = mPendingFragmentActivityResults.valueAt(i);
            }
            outState.putIntArray(ALLOCATED_REQUEST_INDICIES_TAG, requestCodes);
            outState.putStringArray(REQUEST_FRAGMENT_WHO_TAG, fragmentWhos);
        }
    }
/**
     * Save all appropriate fragment state.
     */
Save all appropriate fragment state.
Save all appropriate fragment state .
@Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        markFragmentsCreated();
        Parcelable p = mFragments.saveAllState();
        if (p != null) {
            outState.putParcelable(FRAGMENTS_TAG, p);
        }
        if (mPendingFragmentActivityResults.size() > 0) {
            outState.putInt(NEXT_CANDIDATE_REQUEST_INDEX_TAG, mNextCandidateRequestIndex);
            int[] requestCodes = new int[mPendingFragmentActivityResults.size()];
            String[] fragmentWhos = new String[mPendingFragmentActivityResults.size()];
            for (int i = 0; i < mPendingFragmentActivityResults.size(); i++) {
                requestCodes[i] = mPendingFragmentActivityResults.keyAt(i);
                fragmentWhos[i] = mPendingFragmentActivityResults.valueAt(i);
            }
            outState.putIntArray(ALLOCATED_REQUEST_INDICIES_TAG, requestCodes);
            outState.putStringArray(REQUEST_FRAGMENT_WHO_TAG, fragmentWhos);
        }
    }
@ Override protected void onSaveInstanceState ( Bundle outState ) { super . onSaveInstanceState ( outState ) ; markFragmentsCreated ( ) ; Parcelable p = mFragments . saveAllState ( ) ; if ( p != null ) { outState . putParcelable ( FRAGMENTS_TAG , p ) ; } if ( mPendingFragmentActivityResults . size ( ) > 0 ) { outState . putInt ( NEXT_CANDIDATE_REQUEST_INDEX_TAG , mNextCandidateRequestIndex ) ; int [ ] requestCodes = new int [ mPendingFragmentActivityResults . size ( ) ] ; String [ ] fragmentWhos = new String [ mPendingFragmentActivityResults . size ( ) ] ; for ( int i = 0 ; i < mPendingFragmentActivityResults . size ( ) ; i ++ ) { requestCodes [ i ] = mPendingFragmentActivityResults . keyAt ( i ) ; fragmentWhos [ i ] = mPendingFragmentActivityResults . valueAt ( i ) ; } outState . putIntArray ( ALLOCATED_REQUEST_INDICIES_TAG , requestCodes ) ; outState . putStringArray ( REQUEST_FRAGMENT_WHO_TAG , fragmentWhos ) ; } }
Save all appropriate fragment state.
Save all appropriate fragment state .