# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Ctors | Methods | Inherited Methods

# Dataset.Builder

`public static final class Dataset.Builder`
`extends Object` ``

java.lang.Object
↳ | android.service.autofill.Dataset.Builder

A builder for `Dataset` objects. You must provide at least one value for a field or set an authentication intent.

## Summary

### Public constructors
`Builder(RemoteViews presentation)` Creates a new builder.
`Builder()` Creates a new builder for a dataset where each field will be visualized independently.

### Public methods
`Dataset` | `build()` Creates a new `Dataset` instance.
`Dataset.Builder` | `setAuthentication(IntentSender authentication)` Triggers a custom UI before before autofilling the screen with the contents of this dataset.
`Dataset.Builder` | `setId(String id)` Sets the id for the dataset so its usage can be tracked.
`Dataset.Builder` | `setInlinePresentation(InlinePresentation inlinePresentation)` Sets the `InlinePresentation` used to visualize this dataset as inline suggestions.
`Dataset.Builder` | `setValue(AutofillId id, AutofillValue value, Pattern filter)` Sets the value of a field using an explicit filter.
`Dataset.Builder` | `setValue(AutofillId id, AutofillValue value, Pattern filter, RemoteViews presentation, InlinePresentation inlinePresentation)` Sets the value of a field, using a custom `RemoteViews` to visualize it and a explicit filter, and an `InlinePresentation` to visualize it as an inline suggestion.
`Dataset.Builder` | `setValue(AutofillId id, AutofillValue value, RemoteViews presentation, InlinePresentation inlinePresentation)` Sets the value of a field, using a custom `RemoteViews` to visualize it and an `InlinePresentation` to visualize it as an inline suggestion.
`Dataset.Builder` | `setValue(AutofillId id, AutofillValue value, RemoteViews presentation)` Sets the value of a field, using a custom `RemoteViews` to visualize it.
`Dataset.Builder` | `setValue(AutofillId id, AutofillValue value)` Sets the value of a field.
`Dataset.Builder` | `setValue(AutofillId id, AutofillValue value, Pattern filter, RemoteViews presentation)` Sets the value of a field, using a custom `RemoteViews` to visualize it and a explicit filter.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Public constructors

### Builder

    public Builder (RemoteViews presentation)

Creates a new builder.

Parameters
`presentation` | `RemoteViews`: The presentation used to visualize this dataset. This value cannot be `null`.

### Builder

    public Builder ()

Creates a new builder for a dataset where each field will be visualized independently.

When using this constructor, fields must be set through `setValue(android.view.autofill.AutofillId, android.view.autofill.AutofillValue, android.widget.RemoteViews)` or `setValue(android.view.autofill.AutofillId, android.view.autofill.AutofillValue, java.util.regex.Pattern, android.widget.RemoteViews)`.

## Public methods

### build

    public Dataset build ()

Creates a new `Dataset` instance.

You should not interact with this builder once this method is called.

Returns
`Dataset` | The built dataset. This value cannot be `null`.

Throws
`IllegalStateException` | if no field was set (through `setValue(android.view.autofill.AutofillId, android.view.autofill.AutofillValue)` or `setValue(android.view.autofill.AutofillId, android.view.autofill.AutofillValue, android.widget.RemoteViews)` or `setValue(android.view.autofill.AutofillId, android.view.autofill.AutofillValue, android.widget.RemoteViews, android.service.autofill.InlinePresentation)`), or if `build()` was already called.

### setAuthentication

    public Dataset.Builder setAuthentication (IntentSender authentication)

Triggers a custom UI before before autofilling the screen with the contents of this dataset.

Note: Although the name of this method suggests that it should be used just for authentication flow, it can be used for other advanced flows; see `AutofillService` for examples.

This method is called when you need to provide an authentication UI for the data set. For example, when a data set contains credit card information (such as number, expiration date, and verification code), you can display UI asking for the verification code before filing in the data. Even if the data set is completely populated the system will launch the specified authentication intent and will need your approval to fill it in. Since the data set is "locked" until the user authenticates it, typically this data set name is masked (for example, "VISA....1234"). Typically you would want to store the data set labels non-encrypted and the actual sensitive data encrypted and not in memory. This allows showing the labels in the UI while involving the user if one of the items with these labels is chosen. Note that if you use sensitive data as a label, for example an email address, then it should also be encrypted.

When a user triggers autofill, the system launches the provided intent whose extras will have the `screen content`, and your `client state`. Once you complete your authentication flow you should set the activity result to `Activity.RESULT_OK` and provide the fully populated `Dataset` or a fully-populated `FillResponse` by setting it to the `AutofillManager.EXTRA_AUTHENTICATION_RESULT` extra. If you provide a dataset in the result, it will replace the authenticated dataset and will be immediately filled in. An exception to this behavior is if the original dataset represents a pinned inline suggestion (i.e. any of the field in the dataset has a pinned inline presentation, see `InlinePresentation#isPinned()`), then the original dataset will not be replaced, so that it can be triggered as a pending intent again. If you provide a response, it will replace the current response and the UI will be refreshed. For example, if you provided credit card information without the CVV for the data set in the `FillResponse` then the returned data set should contain the CVV entry.

Note: Do not make the provided pending intent immutable by using `PendingIntent.FLAG_IMMUTABLE` as the platform needs to fill in the authentication arguments.

Parameters
`authentication` | `IntentSender`: Intent to an activity with your authentication flow. This value may be `null`.

Returns
`Dataset.Builder` | this builder. This value cannot be `null`.

Throws
`IllegalStateException` | if `build()` was already called.

See also:

- `PendingIntent`

### setId

    public Dataset.Builder setId (String id)

Sets the id for the dataset so its usage can be tracked.

Dataset usage can be tracked for 2 purposes:

- For statistical purposes, the service can call `AutofillService#getFillEventHistory()` when handling `AutofillService#onFillRequest(FillRequest, android.os.CancellationSignal, FillCallback)` calls.
- For normal autofill workflow, the service can call `SaveRequest#getDatasetIds()` when handling `AutofillService#onSaveRequest(SaveRequest, SaveCallback)` calls.

Parameters
`id` | `String`: id for this dataset or `null` to unset. This value may be `null`.

Returns
`Dataset.Builder` | this builder.

Throws
`IllegalStateException` | if `build()` was already called.

### setInlinePresentation

    public Dataset.Builder setInlinePresentation (InlinePresentation inlinePresentation)

Sets the `InlinePresentation` used to visualize this dataset as inline suggestions. If the dataset supports inline suggestions this should not be null.

Parameters
`inlinePresentation` | `InlinePresentation`: This value cannot be `null`.

Returns
`Dataset.Builder` | this builder.

Throws
`IllegalStateException` | if `build()` was already called.

### setValue

    public Dataset.Builder setValue (AutofillId id,
                    AutofillValue value,
                    Pattern filter)

Sets the value of a field using an explicit filter.

This method is typically used when the dataset requires authentication and the service does not know its value but wants to hide the dataset after the user enters a minimum number of characters. For example, if the dataset represents a credit card number and the service does not want to show the "Tap to authenticate" message until the user tapped 4 digits, in which case the filter would be `Pattern.compile("\\d.{4,}")`.

Note: If the dataset requires authentication but the service knows its text value it's easier to filter by calling `setValue(android.view.autofill.AutofillId, android.view.autofill.AutofillValue)` and use the value to filter.

Parameters
`id` | `AutofillId`: id returned by `AssistStructure.ViewNode.getAutofillId()`. This value cannot be `null`.
`value` | `AutofillValue`: the value to be autofilled. Pass `null` if you do not have the value but the target view is a logical part of the dataset. For example, if the dataset needs authentication and you have no access to the value. This value may be `null`.
`filter` | `Pattern`: regex used to determine if the dataset should be shown in the autofill UI; when `null`, it disables filtering on that dataset (this is the recommended approach when `value` is not `null` and field contains sensitive data such as passwords). This value may be `null`.

Returns
`Dataset.Builder` | this builder.

Throws
`IllegalStateException` | if the builder was constructed without a `RemoteViews` or `build()` was already called.

### setValue

    public Dataset.Builder setValue (AutofillId id,
                    AutofillValue value,
                    Pattern filter,
                    RemoteViews presentation,
                    InlinePresentation inlinePresentation)

Sets the value of a field, using a custom `RemoteViews` to visualize it and a explicit filter, and an `InlinePresentation` to visualize it as an inline suggestion.

This method is typically used when the dataset requires authentication and the service does not know its value but wants to hide the dataset after the user enters a minimum number of characters. For example, if the dataset represents a credit card number and the service does not want to show the "Tap to authenticate" message until the user tapped 4 digits, in which case the filter would be `Pattern.compile("\\d.{4,}")`.

Note: If the dataset requires authentication but the service knows its text value it's easier to filter by calling `setValue(android.view.autofill.AutofillId, android.view.autofill.AutofillValue, android.widget.RemoteViews)` and using the value to filter.

Parameters
`id` | `AutofillId`: id returned by `AssistStructure.ViewNode.getAutofillId()`. This value cannot be `null`.
`value` | `AutofillValue`: the value to be autofilled. Pass `null` if you do not have the value but the target view is a logical part of the dataset. For example, if the dataset needs authentication and you have no access to the value. This value may be `null`.
`filter` | `Pattern`: regex used to determine if the dataset should be shown in the autofill UI; when `null`, it disables filtering on that dataset (this is the recommended approach when `value` is not `null` and field contains sensitive data such as passwords). This value may be `null`.
`presentation` | `RemoteViews`: the presentation used to visualize this field. This value cannot be `null`.
`inlinePresentation` | `InlinePresentation`: The `InlinePresentation` used to visualize this dataset as inline suggestions. If the dataset supports inline suggestions, this should not be null. This value cannot be `null`.

Returns
`Dataset.Builder` | this builder.

Throws
`IllegalStateException` | if `build()` was already called.

### setValue

    public Dataset.Builder setValue (AutofillId id,
                    AutofillValue value,
                    RemoteViews presentation,
                    InlinePresentation inlinePresentation)

Sets the value of a field, using a custom `RemoteViews` to visualize it and an `InlinePresentation` to visualize it as an inline suggestion.

Note: If the dataset requires authentication but the service knows its text value it's easier to filter by calling `setValue(android.view.autofill.AutofillId, android.view.autofill.AutofillValue, android.widget.RemoteViews)` and using the value to filter.

Parameters
`id` | `AutofillId`: id returned by `AssistStructure.ViewNode.getAutofillId()`. This value cannot be `null`.
`value` | `AutofillValue`: the value to be autofilled. Pass `null` if you do not have the value but the target view is a logical part of the dataset. For example, if the dataset needs authentication and you have no access to the value. This value may be `null`.
`presentation` | `RemoteViews`: the presentation used to visualize this field. This value cannot be `null`.
`inlinePresentation` | `InlinePresentation`: The `InlinePresentation` used to visualize this dataset as inline suggestions. If the dataset supports inline suggestions, this should not be null. This value cannot be `null`.

Returns
`Dataset.Builder` | this builder.

Throws
`IllegalStateException` | if `build()` was already called.

### setValue

    public Dataset.Builder setValue (AutofillId id,
                    AutofillValue value,
                    RemoteViews presentation)

Sets the value of a field, using a custom `RemoteViews` to visualize it.

Note: On Android `Build.VERSION_CODES.P` and higher, datasets that require authentication can be also be filtered by passing a `AutofillValue#forText(CharSequence)` as the `value` parameter.

Theme does not work with RemoteViews layout. Avoid hardcoded text color or background color: Autofill on different platforms may have different themes.

Parameters
`id` | `AutofillId`: id returned by `AssistStructure.ViewNode.getAutofillId()`. This value cannot be `null`.
`value` | `AutofillValue`: the value to be autofilled. Pass `null` if you do not have the value but the target view is a logical part of the dataset. For example, if the dataset needs authentication and you have no access to the value. This value may be `null`.
`presentation` | `RemoteViews`: the presentation used to visualize this field. This value cannot be `null`.

Returns
`Dataset.Builder` | this builder.

Throws
`IllegalStateException` | if `build()` was already called.

### setValue

    public Dataset.Builder setValue (AutofillId id,
                    AutofillValue value)

Sets the value of a field. Note: Prior to Android `Build.VERSION_CODES.P`, this method would throw an `IllegalStateException` if this builder was constructed without a `RemoteViews`. Android `Build.VERSION_CODES.P` and higher removed this restriction because datasets used as an `authentication result` do not need a presentation. But if you don't set the presentation in the constructor in a dataset that is meant to be shown to the user, the autofill UI for this field will not be displayed.

Note: On Android `Build.VERSION_CODES.P` and higher, datasets that require authentication can be also be filtered by passing a `AutofillValue#forText(CharSequence)` as the `value` parameter.

Parameters
`id` | `AutofillId`: id returned by `AssistStructure.ViewNode.getAutofillId()`. This value cannot be `null`.
`value` | `AutofillValue`: value to be autofilled. Pass `null` if you do not have the value but the target view is a logical part of the dataset. For example, if the dataset needs authentication and you have no access to the value. This value may be `null`.

Returns
`Dataset.Builder` | this builder.

Throws
`IllegalStateException` | if `build()` was already called.

### setValue

    public Dataset.Builder setValue (AutofillId id,
                    AutofillValue value,
                    Pattern filter,
                    RemoteViews presentation)

Sets the value of a field, using a custom `RemoteViews` to visualize it and a explicit filter.

This method is typically used when the dataset requires authentication and the service does not know its value but wants to hide the dataset after the user enters a minimum number of characters. For example, if the dataset represents a credit card number and the service does not want to show the "Tap to authenticate" message until the user tapped 4 digits, in which case the filter would be `Pattern.compile("\\d.{4,}")`.

Note: If the dataset requires authentication but the service knows its text value it's easier to filter by calling `setValue(android.view.autofill.AutofillId, android.view.autofill.AutofillValue, android.widget.RemoteViews)` and using the value to filter.

Parameters
`id` | `AutofillId`: id returned by `AssistStructure.ViewNode.getAutofillId()`. This value cannot be `null`.
`value` | `AutofillValue`: the value to be autofilled. Pass `null` if you do not have the value but the target view is a logical part of the dataset. For example, if the dataset needs authentication and you have no access to the value. This value may be `null`.
`filter` | `Pattern`: regex used to determine if the dataset should be shown in the autofill UI; when `null`, it disables filtering on that dataset (this is the recommended approach when `value` is not `null` and field contains sensitive data such as passwords). This value may be `null`.
`presentation` | `RemoteViews`: the presentation used to visualize this field. This value cannot be `null`.

Returns
`Dataset.Builder` | this builder.

Throws
`IllegalStateException` | if `build()` was already called.

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*