fragment/src/main/java/androidx/fragment/app/FragmentActivity.java
@Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        mFragments.noteStateNotSaved();
        int requestIndex = requestCode>>16;
        if (requestIndex != 0) {
            requestIndex--;

            String who = mPendingFragmentActivityResults.get(requestIndex);
            mPendingFragmentActivityResults.remove(requestIndex);
            if (who == null) {
                Log.w(TAG, "Activity result delivered for unknown Fragment.");
                return;
            }
            Fragment targetFragment = mFragments.findFragmentByWho(who);
            if (targetFragment == null) {
                Log.w(TAG, "Activity result no fragment exists for who: " + who);
            } else {
                targetFragment.onActivityResult(requestCode & 0xffff, resultCode, data);
            }
            return;
        }

        ActivityCompat.PermissionCompatDelegate delegate =
                ActivityCompat.getPermissionCompatDelegate();
        if (delegate != null && delegate.onActivityResult(this, requestCode, resultCode, data)) {
            // Delegate has handled the activity result
            return;
        }

        super.onActivityResult(requestCode, resultCode, data);
    }
/**
     * Dispatch incoming result to the correct fragment.
     */
Dispatch incoming result to the correct fragment.
Dispatch incoming result to the correct fragment .
@Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        mFragments.noteStateNotSaved();
        int requestIndex = requestCode>>16;
        if (requestIndex != 0) {
            requestIndex--;
            String who = mPendingFragmentActivityResults.get(requestIndex);
            mPendingFragmentActivityResults.remove(requestIndex);
            if (who == null) {
                Log.w(TAG, "Activity result delivered for unknown Fragment.");
                return;
            }
            Fragment targetFragment = mFragments.findFragmentByWho(who);
            if (targetFragment == null) {
                Log.w(TAG, "Activity result no fragment exists for who: " + who);
            } else {
                targetFragment.onActivityResult(requestCode & 0xffff, resultCode, data);
            }
            return;
        }
        ActivityCompat.PermissionCompatDelegate delegate =
                ActivityCompat.getPermissionCompatDelegate();
        if (delegate != null && delegate.onActivityResult(this, requestCode, resultCode, data)) {
            return;
        }
        super.onActivityResult(requestCode, resultCode, data);
    }
@ Override protected void onActivityResult ( int requestCode , int resultCode , @ Nullable Intent data ) { mFragments . noteStateNotSaved ( ) ; int requestIndex = requestCode >> 16 ; if ( requestIndex != 0 ) { requestIndex -- ; String who = mPendingFragmentActivityResults . get ( requestIndex ) ; mPendingFragmentActivityResults . remove ( requestIndex ) ; if ( who == null ) { Log . w ( TAG , "Activity result delivered for unknown Fragment." ) ; return ; } Fragment targetFragment = mFragments . findFragmentByWho ( who ) ; if ( targetFragment == null ) { Log . w ( TAG , "Activity result no fragment exists for who: " + who ) ; } else { targetFragment . onActivityResult ( requestCode & 0xffff , resultCode , data ) ; } return ; } ActivityCompat . PermissionCompatDelegate delegate = ActivityCompat . getPermissionCompatDelegate ( ) ; if ( delegate != null && delegate . onActivityResult ( this , requestCode , resultCode , data ) ) { return ; } super . onActivityResult ( requestCode , resultCode , data ) ; }
Dispatch incoming result to the correct fragment.
Dispatch incoming result to the correct fragment .
// Delegate has handled the activity result