Register now for Android Dev Summit 2019!

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 Int

The platform will determine whether choices will be edited before being sent to the app.

static Int

Tapping on a choice should send the input immediately, without letting the user edit it.

static Int

Tapping on a choice should let the user edit the input before it is sent to the app.

static String

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

static String

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

static Int

The user selected one of the choices from getChoices.

static Int

The user manually entered the data.

Public methods

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

Same as addResultsToIntent but for setting data results.

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

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

Boolean

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

MutableSet<String!>!

Array<CharSequence!>!

Get possible input choices.

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

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

Int

Gets whether tapping on a choice should let the user edit the input before it is sent to the app.

Bundle!

Get additional metadata carried around with this remote input.

CharSequence!

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

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.

static Bundle!

Get the remote input text results bundle from an intent.

static Int
getResultsSource(@NonNull intent: Intent)

Get the source of the RemoteInput results.

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.

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

Set the source of the RemoteInput results.

Constants

EDIT_CHOICES_BEFORE_SENDING_AUTO

static val EDIT_CHOICES_BEFORE_SENDING_AUTO: Int

The platform will determine whether choices will be edited before being sent to the app.

Value: 0

EDIT_CHOICES_BEFORE_SENDING_DISABLED

static val EDIT_CHOICES_BEFORE_SENDING_DISABLED: Int

Tapping on a choice should send the input immediately, without letting the user edit it.

Value: 1

EDIT_CHOICES_BEFORE_SENDING_ENABLED

static val EDIT_CHOICES_BEFORE_SENDING_ENABLED: Int

Tapping on a choice should let the user edit the input before it is sent to the app.

Value: 2

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"

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"

SOURCE_CHOICE

static val SOURCE_CHOICE: Int

The user selected one of the choices from getChoices.

Value: 1

SOURCE_FREE_FORM_INPUT

static val SOURCE_FREE_FORM_INPUT: Int

The user manually entered the data.

Value: 0

Public methods

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.

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.

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.

getAllowedDataTypes

fun getAllowedDataTypes(): MutableSet<String!>!

getChoices

fun getChoices(): Array<CharSequence!>!

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

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:

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

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.

getEditChoicesBeforeSending

fun getEditChoicesBeforeSending(): Int

Gets whether tapping on a choice should let the user edit the input before it is sent to the app.

getExtras

fun getExtras(): Bundle!

Get additional metadata carried around with this remote input.

getLabel

fun getLabel(): CharSequence!

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

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.

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.

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.

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.

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.