@SdkSuppress(minSdkVersion = 17) @Test public void testRemoteInputBuilder_addAndGetDataResultsFromIntent() throws Throwable { Uri uri = Uri.parse("Some Uri"); RemoteInput input = newDataOnlyRemoteInput(); Intent intent = new Intent(); Map<String, Uri> putResults = new HashMap<>(); putResults.put(MIME_TYPE, uri); RemoteInput.addDataResultToIntent(input, intent, putResults); verifyIntentHasDataResults(intent, uri); }
public static void addDataResultToIntent(RemoteInput remoteInput, Intent intent, Map<String, Uri> results) { if (Build.VERSION.SDK_INT >= 26) { android.app.RemoteInput.addDataResultToIntent(fromCompat(remoteInput), intent, results); } else if (Build.VERSION.SDK_INT >= 16) { Intent clipDataIntent = getClipDataIntentFromIntent(intent); if (clipDataIntent == null) { clipDataIntent = new Intent(); } for (Map.Entry<String, Uri> entry : results.entrySet()) { String mimeType = entry.getKey(); Uri uri = entry.getValue(); if (mimeType == null) { continue; } Bundle resultsBundle = clipDataIntent.getBundleExtra(getExtraResultsKeyForData(mimeType)); if (resultsBundle == null) { resultsBundle = new Bundle(); } resultsBundle.putString(remoteInput.getResultKey(), uri.toString()); clipDataIntent.putExtra(getExtraResultsKeyForData(mimeType), resultsBundle); } intent.setClipData(ClipData.newIntent(RemoteInput.RESULTS_CLIP_LABEL, clipDataIntent)); } else { Log.w(TAG, "RemoteInput is only supported from API Level 16"); } }
RemoteInput { public static void addDataResultToIntent(RemoteInput remoteInput, Intent intent, Map<String, Uri> results) { if (Build.VERSION.SDK_INT >= 26) { android.app.RemoteInput.addDataResultToIntent(fromCompat(remoteInput), intent, results); } else if (Build.VERSION.SDK_INT >= 16) { Intent clipDataIntent = getClipDataIntentFromIntent(intent); if (clipDataIntent == null) { clipDataIntent = new Intent(); } for (Map.Entry<String, Uri> entry : results.entrySet()) { String mimeType = entry.getKey(); Uri uri = entry.getValue(); if (mimeType == null) { continue; } Bundle resultsBundle = clipDataIntent.getBundleExtra(getExtraResultsKeyForData(mimeType)); if (resultsBundle == null) { resultsBundle = new Bundle(); } resultsBundle.putString(remoteInput.getResultKey(), uri.toString()); clipDataIntent.putExtra(getExtraResultsKeyForData(mimeType), resultsBundle); } intent.setClipData(ClipData.newIntent(RemoteInput.RESULTS_CLIP_LABEL, clipDataIntent)); } else { Log.w(TAG, "RemoteInput is only supported from API Level 16"); } } }
RemoteInput { public static void addDataResultToIntent(RemoteInput remoteInput, Intent intent, Map<String, Uri> results) { if (Build.VERSION.SDK_INT >= 26) { android.app.RemoteInput.addDataResultToIntent(fromCompat(remoteInput), intent, results); } else if (Build.VERSION.SDK_INT >= 16) { Intent clipDataIntent = getClipDataIntentFromIntent(intent); if (clipDataIntent == null) { clipDataIntent = new Intent(); } for (Map.Entry<String, Uri> entry : results.entrySet()) { String mimeType = entry.getKey(); Uri uri = entry.getValue(); if (mimeType == null) { continue; } Bundle resultsBundle = clipDataIntent.getBundleExtra(getExtraResultsKeyForData(mimeType)); if (resultsBundle == null) { resultsBundle = new Bundle(); } resultsBundle.putString(remoteInput.getResultKey(), uri.toString()); clipDataIntent.putExtra(getExtraResultsKeyForData(mimeType), resultsBundle); } intent.setClipData(ClipData.newIntent(RemoteInput.RESULTS_CLIP_LABEL, clipDataIntent)); } else { Log.w(TAG, "RemoteInput is only supported from API Level 16"); } } RemoteInput(String resultKey, CharSequence label, CharSequence[] choices,
            boolean allowFreeFormTextInput, Bundle extras, Set<String> allowedDataTypes); }
RemoteInput { public static void addDataResultToIntent(RemoteInput remoteInput, Intent intent, Map<String, Uri> results) { if (Build.VERSION.SDK_INT >= 26) { android.app.RemoteInput.addDataResultToIntent(fromCompat(remoteInput), intent, results); } else if (Build.VERSION.SDK_INT >= 16) { Intent clipDataIntent = getClipDataIntentFromIntent(intent); if (clipDataIntent == null) { clipDataIntent = new Intent(); } for (Map.Entry<String, Uri> entry : results.entrySet()) { String mimeType = entry.getKey(); Uri uri = entry.getValue(); if (mimeType == null) { continue; } Bundle resultsBundle = clipDataIntent.getBundleExtra(getExtraResultsKeyForData(mimeType)); if (resultsBundle == null) { resultsBundle = new Bundle(); } resultsBundle.putString(remoteInput.getResultKey(), uri.toString()); clipDataIntent.putExtra(getExtraResultsKeyForData(mimeType), resultsBundle); } intent.setClipData(ClipData.newIntent(RemoteInput.RESULTS_CLIP_LABEL, clipDataIntent)); } else { Log.w(TAG, "RemoteInput is only supported from API Level 16"); } } RemoteInput(String resultKey, CharSequence label, CharSequence[] choices,
            boolean allowFreeFormTextInput, Bundle extras, Set<String> allowedDataTypes); String getResultKey(); CharSequence getLabel(); CharSequence[] getChoices(); Set<String> getAllowedDataTypes(); boolean isDataOnly(); boolean getAllowFreeFormInput(); Bundle getExtras(); static Map<String, Uri> getDataResultsFromIntent(
            Intent intent, String remoteInputResultKey); static Bundle getResultsFromIntent(Intent intent); static void addResultsToIntent(RemoteInput[] remoteInputs, Intent intent,
            Bundle results); static void addDataResultToIntent(RemoteInput remoteInput, Intent intent,
            Map<String, Uri> results); }
RemoteInput { public static void addDataResultToIntent(RemoteInput remoteInput, Intent intent, Map<String, Uri> results) { if (Build.VERSION.SDK_INT >= 26) { android.app.RemoteInput.addDataResultToIntent(fromCompat(remoteInput), intent, results); } else if (Build.VERSION.SDK_INT >= 16) { Intent clipDataIntent = getClipDataIntentFromIntent(intent); if (clipDataIntent == null) { clipDataIntent = new Intent(); } for (Map.Entry<String, Uri> entry : results.entrySet()) { String mimeType = entry.getKey(); Uri uri = entry.getValue(); if (mimeType == null) { continue; } Bundle resultsBundle = clipDataIntent.getBundleExtra(getExtraResultsKeyForData(mimeType)); if (resultsBundle == null) { resultsBundle = new Bundle(); } resultsBundle.putString(remoteInput.getResultKey(), uri.toString()); clipDataIntent.putExtra(getExtraResultsKeyForData(mimeType), resultsBundle); } intent.setClipData(ClipData.newIntent(RemoteInput.RESULTS_CLIP_LABEL, clipDataIntent)); } else { Log.w(TAG, "RemoteInput is only supported from API Level 16"); } } RemoteInput(String resultKey, CharSequence label, CharSequence[] choices,
            boolean allowFreeFormTextInput, Bundle extras, Set<String> allowedDataTypes); String getResultKey(); CharSequence getLabel(); CharSequence[] getChoices(); Set<String> getAllowedDataTypes(); boolean isDataOnly(); boolean getAllowFreeFormInput(); Bundle getExtras(); static Map<String, Uri> getDataResultsFromIntent(
            Intent intent, String remoteInputResultKey); static Bundle getResultsFromIntent(Intent intent); static void addResultsToIntent(RemoteInput[] remoteInputs, Intent intent,
            Bundle results); static void addDataResultToIntent(RemoteInput remoteInput, Intent intent,
            Map<String, Uri> results); static final String RESULTS_CLIP_LABEL; static final String EXTRA_RESULTS_DATA; }