compat/src/main/java/androidx/core/app/RemoteInput.java
public static void addResultsToIntent(RemoteInput[] remoteInputs, Intent intent,
            Bundle results) {
        if (Build.VERSION.SDK_INT >= 26) {
            android.app.RemoteInput.addResultsToIntent(fromCompat(remoteInputs), intent, results);
        } else if (Build.VERSION.SDK_INT >= 20) {
            // Implementations of RemoteInput#addResultsToIntent prior to SDK 26 don't actually add
            // results, they wipe out old results and insert the new one. Work around that by
            // preserving old results.
            Bundle existingTextResults =
                    androidx.core.app.RemoteInput.getResultsFromIntent(intent);
            if (existingTextResults == null) {
                existingTextResults = results;
            } else {
                existingTextResults.putAll(results);
            }
            for (RemoteInput input : remoteInputs) {
                // Data results are also wiped out. So grab them and add them back in.
                Map<String, Uri> existingDataResults =
                        androidx.core.app.RemoteInput.getDataResultsFromIntent(
                                intent, input.getResultKey());
                RemoteInput[] arr = new RemoteInput[1];
                arr[0] = input;
                android.app.RemoteInput.addResultsToIntent(
                        fromCompat(arr), intent, existingTextResults);
                if (existingDataResults != null) {
                    RemoteInput.addDataResultToIntent(input, intent, existingDataResults);
                }
            }
        } else if (Build.VERSION.SDK_INT >= 16) {
            Intent clipDataIntent = getClipDataIntentFromIntent(intent);
            if (clipDataIntent == null) {
                clipDataIntent = new Intent();  // First time we've added a result.
            }
            Bundle resultsBundle = clipDataIntent.getBundleExtra(RemoteInput.EXTRA_RESULTS_DATA);
            if (resultsBundle == null) {
                resultsBundle = new Bundle();
            }
            for (RemoteInput remoteInput : remoteInputs) {
                Object result = results.get(remoteInput.getResultKey());
                if (result instanceof CharSequence) {
                    resultsBundle.putCharSequence(
                            remoteInput.getResultKey(), (CharSequence) result);
                }
            }
            clipDataIntent.putExtra(RemoteInput.EXTRA_RESULTS_DATA, resultsBundle);
            intent.setClipData(ClipData.newIntent(RemoteInput.RESULTS_CLIP_LABEL, clipDataIntent));
        } else {
            Log.w(TAG, "RemoteInput is only supported from API Level 16");
        }
    }
/**
     * Populate an intent object with the results gathered from remote input. This method
     * should only be called by remote input collection services when sending results to a
     * pending intent.
     * @param remoteInputs The remote inputs for which results are being provided
     * @param intent The intent to add remote inputs to. The {@link android.content.ClipData}
     *               field of the intent will be modified to contain the results.
     * @param results A bundle holding the remote input results. This bundle should
     *                be populated with keys matching the result keys specified in
     *                {@code remoteInputs} with values being the result per key.
     */
Populate an intent object with the results gathered from remote input. This method
should only be called by remote input collection services when sending results to a
pending intent.
@param remoteInputs The remote inputs for which results are being provided
@param intent The intent to add remote inputs to. The  android.content.ClipData
field of the intent will be modified to contain the results.
@param results A bundle holding the remote input results. This bundle should
be populated with keys matching the result keys specified in
remoteInputs with values being the result per key.
Populate an intent object with the results gathered from remote input . This method should only be called by remote input collection services when sending results to a pending intent . @param remoteInputs The remote inputs for which results are being provided @param intent The intent to add remote inputs to . The android . content . ClipData field of the intent will be modified to contain the results . @param results A bundle holding the remote input results . This bundle should be populated with keys matching the result keys specified in remoteInputs with values being the result per key .
public static void addResultsToIntent(RemoteInput[] remoteInputs, Intent intent,
            Bundle results) {
        if (Build.VERSION.SDK_INT >= 26) {
            android.app.RemoteInput.addResultsToIntent(fromCompat(remoteInputs), intent, results);
        } else if (Build.VERSION.SDK_INT >= 20) {
            Bundle existingTextResults =
                    androidx.core.app.RemoteInput.getResultsFromIntent(intent);
            if (existingTextResults == null) {
                existingTextResults = results;
            } else {
                existingTextResults.putAll(results);
            }
            for (RemoteInput input : remoteInputs) {
                Map<String, Uri> existingDataResults =
                        androidx.core.app.RemoteInput.getDataResultsFromIntent(
                                intent, input.getResultKey());
                RemoteInput[] arr = new RemoteInput[1];
                arr[0] = input;
                android.app.RemoteInput.addResultsToIntent(
                        fromCompat(arr), intent, existingTextResults);
                if (existingDataResults != null) {
                    RemoteInput.addDataResultToIntent(input, intent, existingDataResults);
                }
            }
        } else if (Build.VERSION.SDK_INT >= 16) {
            Intent clipDataIntent = getClipDataIntentFromIntent(intent);
            if (clipDataIntent == null) {
                clipDataIntent = new Intent();  
            }
            Bundle resultsBundle = clipDataIntent.getBundleExtra(RemoteInput.EXTRA_RESULTS_DATA);
            if (resultsBundle == null) {
                resultsBundle = new Bundle();
            }
            for (RemoteInput remoteInput : remoteInputs) {
                Object result = results.get(remoteInput.getResultKey());
                if (result instanceof CharSequence) {
                    resultsBundle.putCharSequence(
                            remoteInput.getResultKey(), (CharSequence) result);
                }
            }
            clipDataIntent.putExtra(RemoteInput.EXTRA_RESULTS_DATA, resultsBundle);
            intent.setClipData(ClipData.newIntent(RemoteInput.RESULTS_CLIP_LABEL, clipDataIntent));
        } else {
            Log.w(TAG, "RemoteInput is only supported from API Level 16");
        }
    }
public static void addResultsToIntent ( RemoteInput [ ] remoteInputs , Intent intent , Bundle results ) { if ( Build . VERSION . SDK_INT >= 26 ) { android . app . RemoteInput . addResultsToIntent ( fromCompat ( remoteInputs ) , intent , results ) ; } else if ( Build . VERSION . SDK_INT >= 20 ) { Bundle existingTextResults = androidx . core . app . RemoteInput . getResultsFromIntent ( intent ) ; if ( existingTextResults == null ) { existingTextResults = results ; } else { existingTextResults . putAll ( results ) ; } for ( RemoteInput input : remoteInputs ) { Map < String , Uri > existingDataResults = androidx . core . app . RemoteInput . getDataResultsFromIntent ( intent , input . getResultKey ( ) ) ; RemoteInput [ ] arr = new RemoteInput [ 1 ] ; arr [ 0 ] = input ; android . app . RemoteInput . addResultsToIntent ( fromCompat ( arr ) , intent , existingTextResults ) ; if ( existingDataResults != null ) { RemoteInput . addDataResultToIntent ( input , intent , existingDataResults ) ; } } } else if ( Build . VERSION . SDK_INT >= 16 ) { Intent clipDataIntent = getClipDataIntentFromIntent ( intent ) ; if ( clipDataIntent == null ) { clipDataIntent = new Intent ( ) ; } Bundle resultsBundle = clipDataIntent . getBundleExtra ( RemoteInput . EXTRA_RESULTS_DATA ) ; if ( resultsBundle == null ) { resultsBundle = new Bundle ( ) ; } for ( RemoteInput remoteInput : remoteInputs ) { Object result = results . get ( remoteInput . getResultKey ( ) ) ; if ( result instanceof CharSequence ) { resultsBundle . putCharSequence ( remoteInput . getResultKey ( ) , ( CharSequence ) result ) ; } } clipDataIntent . putExtra ( RemoteInput . EXTRA_RESULTS_DATA , resultsBundle ) ; intent . setClipData ( ClipData . newIntent ( RemoteInput . RESULTS_CLIP_LABEL , clipDataIntent ) ) ; } else { Log . w ( TAG , "RemoteInput is only supported from API Level 16" ) ; } }
Populate an intent object with the results gathered from remote input.
Populate an intent object with the results gathered from remote input .
// Implementations of RemoteInput#addResultsToIntent prior to SDK 26 don't actually add // results, they wipe out old results and insert the new one. Work around that by // preserving old results. // Data results are also wiped out. So grab them and add them back in. // First time we've added a result.