public final class

RemoteInput.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.core.app.RemoteInput.Builder

Overview

Builder class for RemoteInput objects.

Summary

Constructors
publicBuilder(java.lang.String resultKey)

Create a builder object for RemoteInput objects.

Methods
public RemoteInput.BuilderaddExtras(Bundle extras)

Merge additional metadata into this builder.

public RemoteInputbuild()

Combine all of the options that have been set and return a new RemoteInput object.

public BundlegetExtras()

Get the metadata Bundle used by this Builder.

public RemoteInput.BuildersetAllowDataType(java.lang.String mimeType, boolean doAllow)

Specifies whether the user can provide arbitrary values.

public RemoteInput.BuildersetAllowFreeFormInput(boolean allowFreeFormTextInput)

Specifies whether the user can provide arbitrary text values.

public RemoteInput.BuildersetChoices(java.lang.CharSequence choices[])

Specifies choices available to the user to satisfy this input.

public RemoteInput.BuildersetEditChoicesBeforeSending(int editChoicesBeforeSending)

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

public RemoteInput.BuildersetLabel(java.lang.CharSequence label)

Set a label to be displayed to the user when collecting this input.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder(java.lang.String resultKey)

Create a builder object for RemoteInput objects.

Parameters:

resultKey: the Bundle key that refers to this input when collected from the user

Methods

public RemoteInput.Builder setLabel(java.lang.CharSequence label)

Set a label to be displayed to the user when collecting this input.

Parameters:

label: The label to show to users when they input a response

Returns:

this object for method chaining

public RemoteInput.Builder setChoices(java.lang.CharSequence choices[])

Specifies choices available to the user to satisfy this input.

Note: Starting in Android P, these choices will always be shown on phones if the app's target SDK is >= P. However, these choices may also be rendered on other types of devices regardless of target SDK.

Parameters:

choices: an array of pre-defined choices for users input. You must provide a non-null and non-empty array if you disabled free form input using RemoteInput.Builder.setAllowFreeFormInput(boolean)

Returns:

this object for method chaining

public RemoteInput.Builder setAllowDataType(java.lang.String mimeType, boolean doAllow)

Specifies whether the user can provide arbitrary values.

Parameters:

mimeType: A mime type that results are allowed to come in. Be aware that text results (see RemoteInput.Builder.setAllowFreeFormInput(boolean) are allowed by default. If you do not want text results you will have to pass false to setAllowFreeFormInput
doAllow: Whether the mime type should be allowed or not

Returns:

this object for method chaining

public RemoteInput.Builder setAllowFreeFormInput(boolean allowFreeFormTextInput)

Specifies whether the user can provide arbitrary text values.

Parameters:

allowFreeFormTextInput: The default is true. If you specify false, you must either provide a non-null and non-empty array to RemoteInput.Builder.setChoices(CharSequence[]), or enable a data result in setAllowDataType. Otherwise an java.lang.IllegalArgumentException is thrown

Returns:

this object for method chaining

public RemoteInput.Builder setEditChoicesBeforeSending(int editChoicesBeforeSending)

Specifies whether tapping on a choice should let the user edit the input before it is sent to the app. The default is RemoteInput.EDIT_CHOICES_BEFORE_SENDING_AUTO. It cannot be used if RemoteInput.Builder.setAllowFreeFormInput(boolean) has been set to false.

public RemoteInput.Builder addExtras(Bundle extras)

Merge additional metadata into this builder.

Values within the Bundle will replace existing extras values in this Builder.

See also: RemoteInput.getExtras()

public Bundle getExtras()

Get the metadata Bundle used by this Builder.

The returned Bundle is shared with this Builder.

public RemoteInput build()

Combine all of the options that have been set and return a new RemoteInput object.