# RemoteInput.Builder

Added in[API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/app/RemoteInput.Builder "View this page in Java")  

```
class Builder
```

|---|--------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                     ||
| ↳ | [android.app.RemoteInput.Builder](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#) |

Builder class for[RemoteInput](https://developer.android.com/reference/kotlin/android/app/RemoteInput)objects.

## Summary

|                                                                                                                                                               Public constructors                                                                                                                                                               ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#Builder(kotlin.String))`(`resultKey:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Create a builder object for[RemoteInput](https://developer.android.com/reference/kotlin/android/app/RemoteInput)objects. |

|                                                                                                                                                                                                                                                      Public methods                                                                                                                                                                                                                                                      ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [RemoteInput.Builder](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#) | [addExtras](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#addExtras(android.os.Bundle))`(`extras:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)`)` Merge additional metadata into this builder.                                                                                                                                            |
| [RemoteInput](https://developer.android.com/reference/kotlin/android/app/RemoteInput)                  | [build](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#build())`()` Combine all of the options that have been set and return a new[RemoteInput](https://developer.android.com/reference/kotlin/android/app/RemoteInput)object.                                                                                                                                                   |
| [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)                       | [getExtras](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#getExtras())`()` Get the metadata Bundle used by this Builder.                                                                                                                                                                                                                                                        |
| [RemoteInput.Builder](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#) | [setAllowDataType](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#setAllowDataType(kotlin.String,%20kotlin.Boolean))`(`mimeType:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `doAllow:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Specifies whether the user can provide arbitrary values. |
| [RemoteInput.Builder](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#) | [setAllowFreeFormInput](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#setAllowFreeFormInput(kotlin.Boolean))`(`allowFreeFormTextInput:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Specifies whether the user can provide arbitrary text values.                                                                                    |
| [RemoteInput.Builder](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#) | [setChoices](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#setChoices(kotlin.Array))`(`choices:` `[Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)<[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!>?`)` Specifies choices available to the user to satisfy this input.                             |
| [RemoteInput.Builder](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#) | [setEditChoicesBeforeSending](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#setEditChoicesBeforeSending(kotlin.Int))`(`editChoicesBeforeSending:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Specifies whether tapping on a choice should let the user edit the input before it is sent to the app.                                         |
| [RemoteInput.Builder](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#) | [setLabel](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#setLabel(kotlin.CharSequence))`(`label:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)?`)` Set a label to be displayed to the user when collecting this input.                                                                                                        |

## Public constructors

### Builder

Added in[API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder(resultKey: String)
```

Create a builder object for[RemoteInput](https://developer.android.com/reference/kotlin/android/app/RemoteInput)objects.

|                                                                                           Parameters                                                                                            ||
|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `resultKey` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun addExtras(extras: Bundle): RemoteInput.Builder
```

Merge additional metadata into this builder.

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

|                                                       Parameters                                                       ||
|----------|--------------------------------------------------------------------------------------------------------------|
| `extras` | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#):This value cannot be`null`. |

|                                                               Return                                                                ||
|--------------------------------------------------------------------------------------------------------|-----------------------------|
| [RemoteInput.Builder](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#) | This value cannot be`null`. |

**See Also**

- [android.app.RemoteInput#getExtras](https://developer.android.com/reference/kotlin/android/app/RemoteInput#getExtras())  

### build

Added in[API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun build(): RemoteInput
```

Combine all of the options that have been set and return a new[RemoteInput](https://developer.android.com/reference/kotlin/android/app/RemoteInput)object.

|                                                       Return                                                       ||
|---------------------------------------------------------------------------------------|-----------------------------|
| [RemoteInput](https://developer.android.com/reference/kotlin/android/app/RemoteInput) | This value cannot be`null`. |

### getExtras

Added in[API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getExtras(): Bundle
```

Get the metadata Bundle used by this Builder.

The returned Bundle is shared with this Builder.

|                                                    Return                                                     ||
|----------------------------------------------------------------------------------|-----------------------------|
| [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#) | This value cannot be`null`. |

### setAllowDataType

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

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

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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):A mime type that results are allowed to come in. Be aware that text results (see[setAllowFreeFormInput](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#setAllowFreeFormInput(kotlin.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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):Whether the mime type should be allowed or not                                                                                                                                                                                                                                                                                                                      |

|                                                                               Return                                                                                ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------|
| [RemoteInput.Builder](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#) | this object for method chaining This value cannot be`null`. |

### setAllowFreeFormInput

Added in[API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setAllowFreeFormInput(allowFreeFormTextInput: Boolean): RemoteInput.Builder
```

Specifies whether the user can provide arbitrary text values.

|                                                                                                                                                                                                                                                            Parameters                                                                                                                                                                                                                                                            ||
|--------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `allowFreeFormTextInput` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):The default is`true`. If you specify`false`, you must either provide a non-null and non-empty array to[setChoices](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#setChoices(kotlin.Array)), or enable a data result in`setAllowDataType`. Otherwise an[IllegalArgumentException](https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html#)is thrown |

|                                                                               Return                                                                                ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------|
| [RemoteInput.Builder](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#) | this object for method chaining This value cannot be`null`. |

### setChoices

Added in[API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\<[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!\>?: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](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#setAllowFreeFormInput(kotlin.Boolean)) |

|                                                                               Return                                                                                ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------|
| [RemoteInput.Builder](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#) | this object for method chaining This value cannot be`null`. |

### setEditChoicesBeforeSending

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://developer.android.com/reference/kotlin/android/app/RemoteInput#EDIT_CHOICES_BEFORE_SENDING_AUTO:kotlin.Int). It cannot be used if[setAllowFreeFormInput](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#setAllowFreeFormInput(kotlin.Boolean))has been set to false.

|                                                                                                                                                                                                                                                                                                                                  Parameters                                                                                                                                                                                                                                                                                                                                  ||
|----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `editChoicesBeforeSending` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is[android.app.RemoteInput#EDIT_CHOICES_BEFORE_SENDING_AUTO](https://developer.android.com/reference/kotlin/android/app/RemoteInput#EDIT_CHOICES_BEFORE_SENDING_AUTO:kotlin.Int),[android.app.RemoteInput#EDIT_CHOICES_BEFORE_SENDING_DISABLED](https://developer.android.com/reference/kotlin/android/app/RemoteInput#EDIT_CHOICES_BEFORE_SENDING_DISABLED:kotlin.Int), or[android.app.RemoteInput#EDIT_CHOICES_BEFORE_SENDING_ENABLED](https://developer.android.com/reference/kotlin/android/app/RemoteInput#EDIT_CHOICES_BEFORE_SENDING_ENABLED:kotlin.Int) |

|                                                               Return                                                                ||
|--------------------------------------------------------------------------------------------------------|-----------------------------|
| [RemoteInput.Builder](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#) | This value cannot be`null`. |

### setLabel

Added in[API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setLabel(label: CharSequence?): RemoteInput.Builder
```

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

|                                                                                       Parameters                                                                                       ||
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `label` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)?:The label to show to users when they input a response This value may be`null`. |

|                                                                               Return                                                                                ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------|
| [RemoteInput.Builder](https://developer.android.com/reference/kotlin/android/app/RemoteInput.Builder#) | this object for method chaining This value cannot be`null`. |