RemoteInput
public
final
class
RemoteInput
extends Object
java.lang.Object | |
↳ | androidx.core.app.RemoteInput |
Helper for using the RemoteInput
.
Summary
Nested classes | |
---|---|
class |
RemoteInput.Builder
Builder class for |
Constants | |
---|---|
int |
EDIT_CHOICES_BEFORE_SENDING_AUTO
The platform will determine whether choices will be edited before being sent to the app. |
int |
EDIT_CHOICES_BEFORE_SENDING_DISABLED
Tapping on a choice should send the input immediately, without letting the user edit it. |
int |
EDIT_CHOICES_BEFORE_SENDING_ENABLED
Tapping on a choice should let the user edit the input before it is sent to the app. |
String |
EXTRA_RESULTS_DATA
Extra added to a clip data intent object to hold the text results bundle. |
String |
RESULTS_CLIP_LABEL
Label used to denote the clip data type used for remote input transport |
int |
SOURCE_CHOICE
The user selected one of the choices from |
int |
SOURCE_FREE_FORM_INPUT
The user manually entered the data. |
Public methods | |
---|---|
static
void
|
addDataResultToIntent(RemoteInput remoteInput, Intent intent, Map<String, Uri> results)
Same as |
static
void
|
addResultsToIntent(RemoteInput[] remoteInputs, Intent intent, Bundle results)
Populate an intent object with the results gathered from remote input. |
boolean
|
getAllowFreeFormInput()
Get whether or not users can provide an arbitrary value for input. |
Set<String>
|
getAllowedDataTypes()
|
CharSequence[]
|
getChoices()
Get possible input choices. |
static
Map<String, Uri>
|
getDataResultsFromIntent(Intent intent, String remoteInputResultKey)
Similar as |
int
|
getEditChoicesBeforeSending()
Gets whether tapping on a choice should let the user edit the input before it is sent to the app. |
Bundle
|
getExtras()
Get additional metadata carried around with this remote input. |
CharSequence
|
getLabel()
Get the label to display to users when collecting this input. |
String
|
getResultKey()
Get the key that the result of this input will be set in from the Bundle returned by
|
static
Bundle
|
getResultsFromIntent(Intent intent)
Get the remote input text results bundle from an intent. |
static
int
|
getResultsSource(Intent intent)
Get the source of the RemoteInput results. |
boolean
|
isDataOnly()
Returns true if the input only accepts data, meaning |
static
void
|
setResultsSource(Intent intent, int source)
Set the source of the RemoteInput results. |
Inherited methods | |
---|---|
Constants
EDIT_CHOICES_BEFORE_SENDING_AUTO
public static final int EDIT_CHOICES_BEFORE_SENDING_AUTO
The platform will determine whether choices will be edited before being sent to the app.
Constant Value: 0 (0x00000000)
EDIT_CHOICES_BEFORE_SENDING_DISABLED
public static final int EDIT_CHOICES_BEFORE_SENDING_DISABLED
Tapping on a choice should send the input immediately, without letting the user edit it.
Constant Value: 1 (0x00000001)
EDIT_CHOICES_BEFORE_SENDING_ENABLED
public static final int EDIT_CHOICES_BEFORE_SENDING_ENABLED
Tapping on a choice should let the user edit the input before it is sent to the app.
Constant Value: 2 (0x00000002)
EXTRA_RESULTS_DATA
public static final String EXTRA_RESULTS_DATA
Extra added to a clip data intent object to hold the text results bundle.
Constant Value: "android.remoteinput.resultsData"
RESULTS_CLIP_LABEL
public static final String RESULTS_CLIP_LABEL
Label used to denote the clip data type used for remote input transport
Constant Value: "android.remoteinput.results"
SOURCE_CHOICE
public static final int SOURCE_CHOICE
The user selected one of the choices from getChoices()
.
Constant Value: 1 (0x00000001)
SOURCE_FREE_FORM_INPUT
public static final int SOURCE_FREE_FORM_INPUT
The user manually entered the data.
Constant Value: 0 (0x00000000)
Public methods
addDataResultToIntent
public static void addDataResultToIntent (RemoteInput remoteInput, Intent intent, Map<String, Uri> results)
Same as addResultsToIntent(RemoteInput[], Intent, Bundle)
but for setting data results.
Parameters | |
---|---|
remoteInput |
RemoteInput : The remote input for which results are being provided |
intent |
Intent : The intent to add remote input results to. The
ClipData field of the intent will be
modified to contain the results. |
results |
Map : A map of mime type to the Uri result for that mime type.
|
addResultsToIntent
public static void addResultsToIntent (RemoteInput[] remoteInputs, Intent intent, Bundle results)
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 |
RemoteInput : The remote inputs for which results are being provided |
intent |
Intent : The intent to add remote inputs to. The ClipData
field of the intent will be modified to contain the results. |
results |
Bundle : 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
public boolean getAllowFreeFormInput ()
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.
Returns | |
---|---|
boolean |
getAllowedDataTypes
public Set<String> getAllowedDataTypes ()
Returns | |
---|---|
Set<String> |
getChoices
public CharSequence[] getChoices ()
Get possible input choices. This can be null
if there are no choices to present.
Returns | |
---|---|
CharSequence[] |
getDataResultsFromIntent
public static Map<String, Uri> getDataResultsFromIntent (Intent intent, String remoteInputResultKey)
Similar as getResultsFromIntent(Intent)
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 |
String : The result key for the RemoteInput you want results for.
|
Returns | |
---|---|
Map<String, Uri> |
getEditChoicesBeforeSending
public int getEditChoicesBeforeSending ()
Gets whether tapping on a choice should let the user edit the input before it is sent to the app.
Returns | |
---|---|
int |
getExtras
public Bundle getExtras ()
Get additional metadata carried around with this remote input.
Returns | |
---|---|
Bundle |
getLabel
public CharSequence getLabel ()
Get the label to display to users when collecting this input.
Returns | |
---|---|
CharSequence |
getResultKey
public String getResultKey ()
Get the key that the result of this input will be set in from the Bundle returned by
getResultsFromIntent(Intent)
when the PendingIntent
is sent.
Returns | |
---|---|
String |
getResultsFromIntent
public static Bundle getResultsFromIntent (Intent intent)
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(Intent, String)
.
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.
|
Returns | |
---|---|
Bundle |
getResultsSource
public static int getResultsSource (Intent intent)
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. |
Returns | |
---|---|
int |
The source of the results. If no source was set, SOURCE_FREE_FORM_INPUT will
be returned.
|
See also:
isDataOnly
public boolean isDataOnly ()
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.
Returns | |
---|---|
boolean |
setResultsSource
public static void setResultsSource (Intent intent, int source)
Set the source of the RemoteInput results. This method should only be called by remote
input collection services (e.g.
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 |
int : The source of the results.
|
See also:
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-02-24 UTC.