fragment/src/main/java/androidx/fragment/app/FragmentActivity.java
@SuppressWarnings("deprecation")
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        mFragments.attachHost(null /*parent*/);

        super.onCreate(savedInstanceState);

        NonConfigurationInstances nc =
                (NonConfigurationInstances) getLastNonConfigurationInstance();
        if (nc != null) {
            mViewModelStore = nc.viewModelStore;
        }
        if (savedInstanceState != null) {
            Parcelable p = savedInstanceState.getParcelable(FRAGMENTS_TAG);
            mFragments.restoreAllState(p, nc != null ? nc.fragments : null);

            // Check if there are any pending onActivityResult calls to descendent Fragments.
            if (savedInstanceState.containsKey(NEXT_CANDIDATE_REQUEST_INDEX_TAG)) {
                mNextCandidateRequestIndex =
                        savedInstanceState.getInt(NEXT_CANDIDATE_REQUEST_INDEX_TAG);
                int[] requestCodes = savedInstanceState.getIntArray(ALLOCATED_REQUEST_INDICIES_TAG);
                String[] fragmentWhos = savedInstanceState.getStringArray(REQUEST_FRAGMENT_WHO_TAG);
                if (requestCodes == null || fragmentWhos == null ||
                            requestCodes.length != fragmentWhos.length) {
                    Log.w(TAG, "Invalid requestCode mapping in savedInstanceState.");
                } else {
                    mPendingFragmentActivityResults = new SparseArrayCompat<>(requestCodes.length);
                    for (int i = 0; i < requestCodes.length; i++) {
                        mPendingFragmentActivityResults.put(requestCodes[i], fragmentWhos[i]);
                    }
                }
            }
        }

        if (mPendingFragmentActivityResults == null) {
            mPendingFragmentActivityResults = new SparseArrayCompat<>();
            mNextCandidateRequestIndex = 0;
        }

        mFragments.dispatchCreate();
    }
/**
     * Perform initialization of all fragments.
     */
Perform initialization of all fragments.
Perform initialization of all fragments .
@SuppressWarnings("deprecation")
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        mFragments.attachHost(null /*parent*/);
        super.onCreate(savedInstanceState);
        NonConfigurationInstances nc =
                (NonConfigurationInstances) getLastNonConfigurationInstance();
        if (nc != null) {
            mViewModelStore = nc.viewModelStore;
        }
        if (savedInstanceState != null) {
            Parcelable p = savedInstanceState.getParcelable(FRAGMENTS_TAG);
            mFragments.restoreAllState(p, nc != null ? nc.fragments : null);
            if (savedInstanceState.containsKey(NEXT_CANDIDATE_REQUEST_INDEX_TAG)) {
                mNextCandidateRequestIndex =
                        savedInstanceState.getInt(NEXT_CANDIDATE_REQUEST_INDEX_TAG);
                int[] requestCodes = savedInstanceState.getIntArray(ALLOCATED_REQUEST_INDICIES_TAG);
                String[] fragmentWhos = savedInstanceState.getStringArray(REQUEST_FRAGMENT_WHO_TAG);
                if (requestCodes == null || fragmentWhos == null ||
                            requestCodes.length != fragmentWhos.length) {
                    Log.w(TAG, "Invalid requestCode mapping in savedInstanceState.");
                } else {
                    mPendingFragmentActivityResults = new SparseArrayCompat<>(requestCodes.length);
                    for (int i = 0; i < requestCodes.length; i++) {
                        mPendingFragmentActivityResults.put(requestCodes[i], fragmentWhos[i]);
                    }
                }
            }
        }
        if (mPendingFragmentActivityResults == null) {
            mPendingFragmentActivityResults = new SparseArrayCompat<>();
            mNextCandidateRequestIndex = 0;
        }
        mFragments.dispatchCreate();
    }
@ SuppressWarnings ( "deprecation" ) @ Override protected void onCreate ( @ Nullable Bundle savedInstanceState ) { mFragments . attachHost ( null /*parent*/ ) ; super . onCreate ( savedInstanceState ) ; NonConfigurationInstances nc = ( NonConfigurationInstances ) getLastNonConfigurationInstance ( ) ; if ( nc != null ) { mViewModelStore = nc . viewModelStore ; } if ( savedInstanceState != null ) { Parcelable p = savedInstanceState . getParcelable ( FRAGMENTS_TAG ) ; mFragments . restoreAllState ( p , nc != null ? nc . fragments : null ) ; if ( savedInstanceState . containsKey ( NEXT_CANDIDATE_REQUEST_INDEX_TAG ) ) { mNextCandidateRequestIndex = savedInstanceState . getInt ( NEXT_CANDIDATE_REQUEST_INDEX_TAG ) ; int [ ] requestCodes = savedInstanceState . getIntArray ( ALLOCATED_REQUEST_INDICIES_TAG ) ; String [ ] fragmentWhos = savedInstanceState . getStringArray ( REQUEST_FRAGMENT_WHO_TAG ) ; if ( requestCodes == null || fragmentWhos == null || requestCodes . length != fragmentWhos . length ) { Log . w ( TAG , "Invalid requestCode mapping in savedInstanceState." ) ; } else { mPendingFragmentActivityResults = new SparseArrayCompat < > ( requestCodes . length ) ; for ( int i = 0 ; i < requestCodes . length ; i ++ ) { mPendingFragmentActivityResults . put ( requestCodes [ i ] , fragmentWhos [ i ] ) ; } } } } if ( mPendingFragmentActivityResults == null ) { mPendingFragmentActivityResults = new SparseArrayCompat < > ( ) ; mNextCandidateRequestIndex = 0 ; } mFragments . dispatchCreate ( ) ; }
Perform initialization of all fragments.
Perform initialization of all fragments .
// Check if there are any pending onActivityResult calls to descendent Fragments.