RemoteInput.Builder


public static final class RemoteInput.Builder
extends Object

java.lang.Object
   ↳ android.app.RemoteInput.Builder


Builder class for RemoteInput objects.

Summary

Public constructors

Builder(String resultKey)

Create a builder object for RemoteInput objects.

Public methods

RemoteInput.Builder addExtras(Bundle extras)

Merge additional metadata into this builder.

RemoteInput build()

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

Bundle getExtras()

Get the metadata Bundle used by this Builder.

RemoteInput.Builder setAllowDataType(String mimeType, boolean doAllow)

Specifies whether the user can provide arbitrary values.

RemoteInput.Builder setAllowFreeFormInput(boolean allowFreeFormTextInput)

Specifies whether the user can provide arbitrary text values.

RemoteInput.Builder setChoices(CharSequence[] choices)

Specifies choices available to the user to satisfy this input.

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.

RemoteInput.Builder setLabel(CharSequence label)

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

Inherited methods

Public constructors

Builder

Added in API level 20
public Builder (String resultKey)

Create a builder object for RemoteInput objects.

Parameters
resultKey String: the Bundle key that refers to this input when collected from the user This value cannot be null.

Public methods

addExtras

Added in API level 20
public RemoteInput.Builder addExtras (Bundle extras)

Merge additional metadata into this builder.

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

Parameters
extras Bundle: This value cannot be null.

Returns
RemoteInput.Builder This value cannot be null.

build

Added in API level 20
public RemoteInput build ()

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

Returns
RemoteInput This value cannot be null.

getExtras

Added in API level 20
public Bundle getExtras ()

Get the metadata Bundle used by this Builder.

The returned Bundle is shared with this Builder.

Returns
Bundle This value cannot be null.

setAllowDataType

Added in API level 26
public RemoteInput.Builder setAllowDataType (String mimeType, 
                boolean doAllow)

Specifies whether the user can provide arbitrary values. This allows an input to accept non-textual values. Examples of usage are an input that wants audio or an image.

Parameters
mimeType String: A mime type that results are allowed to come in. Be aware that text results (see setAllowFreeFormInput(boolean) are allowed by default. If you do not want text results you will have to pass false to setAllowFreeFormInput This value cannot be null.

doAllow boolean: Whether the mime type should be allowed or not

Returns
RemoteInput.Builder this object for method chaining This value cannot be null.

setAllowFreeFormInput

Added in API level 20
public RemoteInput.Builder setAllowFreeFormInput (boolean allowFreeFormTextInput)

Specifies whether the user can provide arbitrary text values.

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

Returns
RemoteInput.Builder this object for method chaining This value cannot be null.

setChoices

Added in API level 20
public RemoteInput.Builder setChoices (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 CharSequence: 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 setAllowFreeFormInput(boolean)

Returns
RemoteInput.Builder this object for method chaining This value cannot be null.

setEditChoicesBeforeSending

Added in API level 29
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 setAllowFreeFormInput(boolean) has been set to false.

Parameters
editChoicesBeforeSending int: Value is RemoteInput.EDIT_CHOICES_BEFORE_SENDING_AUTO, RemoteInput.EDIT_CHOICES_BEFORE_SENDING_DISABLED, or RemoteInput.EDIT_CHOICES_BEFORE_SENDING_ENABLED

Returns
RemoteInput.Builder This value cannot be null.

setLabel

Added in API level 20
public RemoteInput.Builder setLabel (CharSequence label)

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

Parameters
label CharSequence: The label to show to users when they input a response This value may be null.

Returns
RemoteInput.Builder this object for method chaining This value cannot be null.