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

# Builder

*** ** * ** ***

```
class Builder
```

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

A builder for `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo` objects.

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#Builder(kotlin.Int)(type: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Creates a new builder when no id is required. |
| `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#Builder(kotlin.Int,%20kotlin.Array)(type: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, requiredIds: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#!>)` Creates a new builder. |

| Public methods ||
|---|---|
| [SaveInfo.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#addSanitizer(android.service.autofill.Sanitizer,%20android.view.autofill.AutofillId)(sanitizer: https://developer.android.com/reference/kotlin/android/service/autofill/Sanitizer, vararg ids: https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#!)` Adds a sanitizer for one or more field. |
| [SaveInfo](https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo)! | `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#build()()` Builds a new `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo` instance. |
| [SaveInfo.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#setCustomDescription(android.service.autofill.CustomDescription)(customDescription: https://developer.android.com/reference/kotlin/android/service/autofill/CustomDescription)` Sets a custom description to be shown in the UI when the user is asked to save. |
| [SaveInfo.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#setDescription(kotlin.CharSequence)(description: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html?)` Sets an optional description to be shown in the UI when the user is asked to save. |
| [SaveInfo.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#setFlags(kotlin.Int)(flags: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets flags changing the save behavior. |
| [SaveInfo.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#setNegativeAction(kotlin.Int,%20android.content.IntentSender)(style: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, listener: https://developer.android.com/reference/kotlin/android/content/IntentSender.html#?)` Sets the style and listener for the negative save action. |
| [SaveInfo.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#setOptionalIds(kotlin.Array)(ids: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#!>)` Sets the ids of additional, optional views the service would be interested to save. |
| [SaveInfo.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#setPositiveAction(kotlin.Int)(style: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the style for the positive save action. |
| [SaveInfo.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#setTriggerId(android.view.autofill.AutofillId)(id: https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#)` Explicitly defines the view that should commit the autofill context when clicked. |
| [SaveInfo.Builder](https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#setValidator(android.service.autofill.Validator)(validator: https://developer.android.com/reference/kotlin/android/service/autofill/Validator)` Sets an object used to validate the user input - if the input is not valid, the autofill save UI is not shown. |

## Public constructors

### Builder

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

```
Builder(type: Int)
```

Creates a new builder when no id is required.

When using this builder, caller must call `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#setOptionalIds(kotlin.Array)` before calling `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#build()`.

| Parameters ||
|---|---|
| `type` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the type of information the associated `https://developer.android.com/reference/kotlin/android/service/autofill/FillResponse` represents. It can be any combination of `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_GENERIC:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_PASSWORD:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_ADDRESS:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_CREDIT_CARD:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_DEBIT_CARD:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_PAYMENT_CARD:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_GENERIC_CARD:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_USERNAME:kotlin.Int`, or `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_EMAIL_ADDRESS:kotlin.Int`. See `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo` for more info. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_GENERIC:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_PASSWORD:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_ADDRESS:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_CREDIT_CARD:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_USERNAME:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_EMAIL_ADDRESS:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_DEBIT_CARD:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_PAYMENT_CARD:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_GENERIC_CARD:kotlin.Int` |

### Builder

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

```
Builder(
    type: Int, 
    requiredIds: Array<AutofillId!>)
```

Creates a new builder.

| Parameters ||
|---|---|
| `type` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the type of information the associated `https://developer.android.com/reference/kotlin/android/service/autofill/FillResponse` represents. It can be any combination of `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_GENERIC:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_PASSWORD:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_ADDRESS:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_CREDIT_CARD:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_DEBIT_CARD:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_PAYMENT_CARD:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_GENERIC_CARD:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_USERNAME:kotlin.Int`, or `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_EMAIL_ADDRESS:kotlin.Int`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_GENERIC:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_PASSWORD:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_ADDRESS:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_CREDIT_CARD:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_USERNAME:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_EMAIL_ADDRESS:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_DEBIT_CARD:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_PAYMENT_CARD:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#SAVE_DATA_TYPE_GENERIC_CARD:kotlin.Int` |
| `requiredIds` | [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\<[AutofillId](https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#)!\>: ids of all required views that will trigger a save request. See `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo` for more info. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if `requiredIds` is `null` or empty, or if it contains any `null` entry. |

## Public methods

### addSanitizer

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

```
fun addSanitizer(
    sanitizer: Sanitizer, 
    vararg ids: AutofillId!
): SaveInfo.Builder
```

Adds a sanitizer for one or more field.

When a sanitizer is set for a field, the `https://developer.android.com/reference/kotlin/android/view/autofill/AutofillValue.html#` is sent to the sanitizer before a save request is [triggered](https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#TriggeringSaveRequest).

Typically used to avoid displaying the save UI for values that are autofilled but reformattedby the app. For example, to remove spaces between every 4 digits of a credit card number:

```kotlin
builder.addSanitizer(new TextValueSanitizer(
      Pattern.compile("^(\\d{4})\\s?(\\d{4})\\s?(\\d{4})\\s?(\\d{4})$", "$1$2$3$4")),
      ccNumberId);
  
```

The same sanitizer can be reused to sanitize multiple fields. For example, to trim both the username and password fields:

```kotlin
builder.addSanitizer(
      new TextValueSanitizer(Pattern.compile("^\\s*(.*)\\s*$"), "$1"),
          usernameId, passwordId);
  
```

The sanitizer can also be used as an alternative for a `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#setValidator(android.service.autofill.Validator)`. If any of the `ids` is a `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#Builder(kotlin.Int,%20kotlin.Array)` and the `sanitizer` fails because of it, then the save UI is not shown.

| Parameters ||
|---|---|
| `sanitizer` | [Sanitizer](https://developer.android.com/reference/kotlin/android/service/autofill/Sanitizer): an implementation provided by the Android System. This value cannot be `null`. |
| `ids` | [AutofillId](https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#)!: id of fields whose value will be sanitized. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#` | this builder. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if a sanitizer for any of the `ids` has already been added or if `ids` is empty. |

### build

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

```
fun build(): SaveInfo!
```

Builds a new `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo` instance. If no `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#Builder(kotlin.Int,%20kotlin.Array)`, or `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#setOptionalIds(kotlin.Array)`, or `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#FLAG_DELAY_SAVE:kotlin.Int` were set, Save Dialog will only be triggered if platform detection is enabled, which is indicated when `https://developer.android.com/reference/kotlin/android/service/autofill/FillRequest#getHints()` is not empty.

### setCustomDescription

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

```
fun setCustomDescription(customDescription: CustomDescription): SaveInfo.Builder
```

Sets a custom description to be shown in the UI when the user is asked to save.

Typically used when the service must show more info about the object being saved, like a credit card logo, masked number, and expiration date.

| Parameters ||
|---|---|
| `customDescription` | [CustomDescription](https://developer.android.com/reference/kotlin/android/service/autofill/CustomDescription): the custom description. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#` | This Builder. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalStateException` | if this call was made after calling `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#setDescription(kotlin.CharSequence)`. |

### setDescription

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

```
fun setDescription(description: CharSequence?): SaveInfo.Builder
```

Sets an optional description to be shown in the UI when the user is asked to save.

Typically, it describes how the data will be stored by the service, so it can help users to decide whether they can trust the service to save their data.

| Parameters ||
|---|---|
| `description` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)?: a succint description. This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#` | This Builder. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalStateException` | if this call was made after calling `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#setCustomDescription(android.service.autofill.CustomDescription)`. |

### setFlags

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

```
fun setFlags(flags: Int): SaveInfo.Builder
```

Sets flags changing the save behavior.

| Parameters ||
|---|---|
| `flags` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#FLAG_DONT_SAVE_ON_FINISH:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#FLAG_DELAY_SAVE:kotlin.Int`, or `0`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#FLAG_DONT_SAVE_ON_FINISH:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#FLAG_DELAY_SAVE:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#` | This builder. This value cannot be `null`. |

### setNegativeAction

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

```
fun setNegativeAction(
    style: Int, 
    listener: IntentSender?
): SaveInfo.Builder
```

Sets the style and listener for the negative save action.

This allows an autofill service to customize the style and be notified when the user selects the negative action in the save UI. Note that selecting the negative action regardless of its style and listener being customized would dismiss the save UI and if a custom listener intent is provided then this intent is started. The default style is `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#NEGATIVE_BUTTON_STYLE_CANCEL:kotlin.Int`

| Parameters ||
|---|---|
| `style` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The action style. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#NEGATIVE_BUTTON_STYLE_CANCEL:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#NEGATIVE_BUTTON_STYLE_REJECT:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#NEGATIVE_BUTTON_STYLE_NEVER:kotlin.Int` |
| `listener` | [IntentSender](https://developer.android.com/reference/kotlin/android/content/IntentSender.html#)?: The action listener. This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#` | This builder. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | If the style is invalid |

**See Also**

- `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#NEGATIVE_BUTTON_STYLE_CANCEL:kotlin.Int`
- `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#NEGATIVE_BUTTON_STYLE_REJECT:kotlin.Int`
- `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#NEGATIVE_BUTTON_STYLE_NEVER:kotlin.Int`

### setOptionalIds

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

```
fun setOptionalIds(ids: Array<AutofillId!>): SaveInfo.Builder
```

Sets the ids of additional, optional views the service would be interested to save.

See `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo` for more info.

| Parameters ||
|---|---|
| `ids` | [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\<[AutofillId](https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#)!\>: The ids of the optional views. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#` | This builder. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if `ids` is `null` or empty, or if it contains any `null` entry. |

### setPositiveAction

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

```
fun setPositiveAction(style: Int): SaveInfo.Builder
```

Sets the style for the positive save action.

This allows an autofill service to customize the style of the positive action in the save UI. Note that selecting the positive action regardless of its style would dismiss the save UI and calling into the `https://developer.android.com/reference/kotlin/android/service/autofill/AutofillService#onSaveRequest(android.service.autofill.SaveRequest,%20android.service.autofill.SaveCallback)`. The service should take the next action if selecting style `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#POSITIVE_BUTTON_STYLE_CONTINUE:kotlin.Int`. The default style is `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#POSITIVE_BUTTON_STYLE_SAVE:kotlin.Int`

| Parameters ||
|---|---|
| `style` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The action style. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#POSITIVE_BUTTON_STYLE_SAVE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#POSITIVE_BUTTON_STYLE_CONTINUE:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#` | This builder. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | If the style is invalid |

**See Also**

- `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#POSITIVE_BUTTON_STYLE_SAVE:kotlin.Int`
- `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo#POSITIVE_BUTTON_STYLE_CONTINUE:kotlin.Int`

### setTriggerId

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

```
fun setTriggerId(id: AutofillId): SaveInfo.Builder
```

Explicitly defines the view that should commit the autofill context when clicked.

Usually, the save request is only automatically [triggered](https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#TriggeringSaveRequest) after the activity is finished or all relevant views become invisible, but there are scenarios where the autofill context is automatically commited too late ---for example, when the activity manually clears the autofillable views when a button is tapped. This method can be used to trigger the autofill save UI earlier in these scenarios.

**Note:** This method should only be used in scenarios where the automatic workflow is not enough, otherwise it could trigger the autofill save UI when it should not--- for example, when the user entered invalid credentials for the autofillable views.

| Parameters ||
|---|---|
| `id` | [AutofillId](https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#): This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#` | This value cannot be `null`. |

### setValidator

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

```
fun setValidator(validator: Validator): SaveInfo.Builder
```

Sets an object used to validate the user input - if the input is not valid, the autofill save UI is not shown.

Typically used to validate credit card numbers. Examples:

Validator for a credit number that must have exactly 16 digits:

```kotlin
Validator validator = new RegexValidator(ccNumberId, Pattern.compile(""^\\d{16}$"))
  
```

Validator for a credit number that must pass a Luhn checksum and either have 16 digits, or 15 digits starting with 108:

```kotlin
import static android.service.autofill.Validators.and;
  import static android.service.autofill.Validators.or;
 
  Validator validator =
    and(
      new LuhnChecksumValidator(ccNumberId),
      or(
        new RegexValidator(ccNumberId, Pattern.compile("^\\d{16}$")),
        new RegexValidator(ccNumberId, Pattern.compile("^108\\d{12}$"))
      )
    );
  
```

**Note:** the example above is just for illustrative purposes; the same validator could be created using a single regex for the `OR` part:

```kotlin
Validator validator =
    and(
      new LuhnChecksumValidator(ccNumberId),
      new RegexValidator(ccNumberId, Pattern.compile(""^(\\d{16}|108\\d{12})$"))
    );
  
```

Validator for a credit number contained in just 4 fields and that must have exactly 4 digits on each field:

```kotlin
import static android.service.autofill.Validators.and;
 
  Validator validator =
    and(
      new RegexValidator(ccNumberId1, Pattern.compile("^\\d{4}$")),
      new RegexValidator(ccNumberId2, Pattern.compile("^\\d{4}$")),
      new RegexValidator(ccNumberId3, Pattern.compile("^\\d{4}$")),
      new RegexValidator(ccNumberId4, Pattern.compile("^\\d{4}$"))
    );
  
```

| Parameters ||
|---|---|
| `validator` | [Validator](https://developer.android.com/reference/kotlin/android/service/autofill/Validator): an implementation provided by the Android System. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/service/autofill/SaveInfo.Builder#` | this builder. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if `validator` is not a class provided by the Android System. |