RemoteInput.Builder

Added in 1.1.0

class RemoteInput.Builder


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

Summary

Public constructors

Builder(resultKey: String)

Create a builder object for androidx.core.app.RemoteInput objects.

Public functions

RemoteInput.Builder
addExtras(extras: Bundle)

Merge additional metadata into this builder.

RemoteInput

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

Bundle

Get the metadata Bundle used by this Builder.

RemoteInput.Builder
setAllowDataType(mimeType: String, doAllow: Boolean)

Specifies whether the user can provide arbitrary values.

RemoteInput.Builder
setAllowFreeFormInput(allowFreeFormTextInput: Boolean)

Specifies whether the user can provide arbitrary text values.

RemoteInput.Builder

Specifies choices available to the user to satisfy this input.

RemoteInput.Builder
setEditChoicesBeforeSending(editChoicesBeforeSending: Int)

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

RemoteInput.Builder

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

Public constructors

Builder

Added in 1.1.0
Builder(resultKey: String)

Create a builder object for androidx.core.app.RemoteInput objects.

Parameters
resultKey: String

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

Public functions

addExtras

Added in 1.1.0
fun addExtras(extras: Bundle): RemoteInput.Builder

Merge additional metadata into this builder.

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

See also
getExtras

build

Added in 1.1.0
fun build(): RemoteInput

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

getExtras

Added in 1.1.0
fun getExtras(): Bundle

Get the metadata Bundle used by this Builder.

The returned Bundle is shared with this Builder.

setAllowDataType

Added in 1.1.0
fun setAllowDataType(mimeType: String, doAllow: Boolean): RemoteInput.Builder

Specifies whether the user can provide arbitrary values.

Parameters
mimeType: String

A mime type that results are allowed to come in. Be aware that text results (see setAllowFreeFormInput are allowed by default. If you do not want text results you will have to pass false to setAllowFreeFormInput

doAllow: Boolean

Whether the mime type should be allowed or not

Returns
RemoteInput.Builder

this object for method chaining

setAllowFreeFormInput

Added in 1.1.0
fun setAllowFreeFormInput(allowFreeFormTextInput: Boolean): RemoteInput.Builder

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, or enable a data result in setAllowDataType. Otherwise an IllegalArgumentException is thrown

Returns
RemoteInput.Builder

this object for method chaining

setChoices

Added in 1.1.0
fun setChoices(choices: Array<CharSequence!>?): RemoteInput.Builder

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: Array<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

Returns
RemoteInput.Builder

this object for method chaining

setEditChoicesBeforeSending

Added in 1.2.0
fun setEditChoicesBeforeSending(editChoicesBeforeSending: Int): RemoteInput.Builder

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

setLabel

Added in 1.1.0
fun setLabel(label: CharSequence?): RemoteInput.Builder

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

Returns
RemoteInput.Builder

this object for method chaining