RemoteInput

class RemoteInput
kotlin.Any
   ↳ androidx.core.app.RemoteInput

Helper for using the android.app.RemoteInput.

Summary

Nested classes

Builder class for androidx.core.app.RemoteInput objects.

Constants
static String

Label used to denote the clip data type used for remote input transport

static String

Extra added to a clip data intent object to hold the text results bundle.

static Int

The user manually entered the data.

static Int

The user selected one of the choices from getChoices.

Public methods
Boolean

Returns true if the input only accepts data, meaning getAllowFreeFormInput is false, getChoices is null or empty, and getAllowedDataTypes is non-null and not empty.

String!

Get the key that the result of this input will be set in from the Bundle returned by getResultsFromIntent when the android.app.PendingIntent is sent.

Array<CharSequence!>!

Get possible input choices.

CharSequence!

Get the label to display to users when collecting this input.

MutableSet<String!>!

Bundle!

Get additional metadata carried around with this remote input.

Boolean

Get whether or not users can provide an arbitrary value for input.

static MutableMap<String!, Uri!>!
getDataResultsFromIntent(intent: Intent!, remoteInputResultKey: String!)

Similar as getResultsFromIntent but retrieves data results for a specific RemoteInput result.

static Bundle!

Get the remote input text results bundle from an intent.

static Unit
addResultsToIntent(remoteInputs: Array<RemoteInput!>!, intent: Intent!, results: Bundle!)

Populate an intent object with the results gathered from remote input.

static Unit
addDataResultToIntent(remoteInput: RemoteInput!, intent: Intent!, results: MutableMap<String!, Uri!>!)

Same as addResultsToIntent but for setting data results.

static Unit
setResultsSource(@NonNull intent: Intent, source: Int)

Set the source of the RemoteInput results.

static Int
getResultsSource(@NonNull intent: Intent)

Get the source of the RemoteInput results.

Constants

RESULTS_CLIP_LABEL

static val RESULTS_CLIP_LABEL: String

Label used to denote the clip data type used for remote input transport

Value: "android.remoteinput.results"

EXTRA_RESULTS_DATA

static val EXTRA_RESULTS_DATA: String

Extra added to a clip data intent object to hold the text results bundle.

Value: "android.remoteinput.resultsData"

SOURCE_FREE_FORM_INPUT

static val SOURCE_FREE_FORM_INPUT: Int

The user manually entered the data.

Value: 0

SOURCE_CHOICE

static val SOURCE_CHOICE: Int

The user selected one of the choices from getChoices.

Value: 1

Public methods

isDataOnly

fun isDataOnly(): Boolean

Returns true if the input only accepts data, meaning getAllowFreeFormInput is false, getChoices is null or empty, and getAllowedDataTypes is non-null and not empty.

getResultKey

fun getResultKey(): String!

Get the key that the result of this input will be set in from the Bundle returned by getResultsFromIntent when the android.app.PendingIntent is sent.

getChoices

fun getChoices(): Array<CharSequence!>!

Get possible input choices. This can be null if there are no choices to present.

getLabel

fun getLabel(): CharSequence!

Get the label to display to users when collecting this input.

getAllowedDataTypes

fun getAllowedDataTypes(): MutableSet<String!>!

getExtras

fun getExtras(): Bundle!

Get additional metadata carried around with this remote input.

getAllowFreeFormInput

fun getAllowFreeFormInput(): Boolean

Get whether or not users can provide an arbitrary value for input. If you set this to false, users must select one of the choices in getChoices. An IllegalArgumentException is thrown if you set this to false and getChoices returns null or empty.

getDataResultsFromIntent

static fun getDataResultsFromIntent(intent: Intent!, remoteInputResultKey: String!): MutableMap<String!, Uri!>!

Similar as getResultsFromIntent but retrieves data results for a specific RemoteInput result. To retrieve a value use:

 Map<String, Uri> results = RemoteInput.getDataResultsFromIntent(intent, REMOTE_INPUT_KEY); if (results != null) { Uri data = results.get(MIME_TYPE_OF_INTEREST); }  

Parameters
intent Intent!: The intent object that fired in response to an action or content intent which also had one or more remote input requested.
remoteInputResultKey Intent!: The result key for the RemoteInput you want results for.

getResultsFromIntent

static fun getResultsFromIntent(intent: Intent!): Bundle!

Get the remote input text results bundle from an intent. The returned Bundle will contain a key/value for every result key populated by remote input collector. Use the Bundle#getCharSequence(String) method to retrieve a value. For data results use getDataResultsFromIntent.

Parameters
intent Intent!: The intent object that fired in response to an action or content intent which also had one or more remote input requested.

addResultsToIntent

static fun addResultsToIntent(remoteInputs: Array<RemoteInput!>!, intent: Intent!, results: Bundle!): Unit

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.

Parameters
remoteInputs Array<RemoteInput!>!: The remote inputs for which results are being provided
intent Array<RemoteInput!>!: The intent to add remote inputs to. The android.content.ClipData field of the intent will be modified to contain the results.
results Array<RemoteInput!>!: 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.

addDataResultToIntent

static fun addDataResultToIntent(remoteInput: RemoteInput!, intent: Intent!, results: MutableMap<String!, Uri!>!): Unit

Same as addResultsToIntent but for setting data results.

Parameters
remoteInput RemoteInput!: The remote input for which results are being provided
intent RemoteInput!: The intent to add remote input results to. The android.content.ClipData field of the intent will be modified to contain the results.
results RemoteInput!: A map of mime type to the Uri result for that mime type.

setResultsSource

static fun setResultsSource(@NonNull intent: Intent, source: Int): Unit

Set the source of the RemoteInput results. This method should only be called by remote input collection services (e.g. android.service.notification.NotificationListenerService) when sending results to a pending intent.

Parameters
intent Intent: The intent to add remote input source to. The ClipData field of the intent will be modified to contain the source.
source Intent: The source of the results.

getResultsSource

static fun getResultsSource(@NonNull intent: Intent): Int

Get the source of the RemoteInput results.

Parameters
intent Intent: The intent object that fired in response to an action or content intent which also had one or more remote input requested.
Return
Int: The source of the results. If no source was set, SOURCE_FREE_FORM_INPUT will be returned.