Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/view/autofill/AutofillManager#nestedclasses) \| [Constants](https://developer.android.com/reference/android/view/autofill/AutofillManager#constants) \| [Methods](https://developer.android.com/reference/android/view/autofill/AutofillManager#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/autofill/AutofillManager#inhmethods)

# AutofillManager

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/view/autofill/AutofillManager "View this page in Kotlin") \|Java


`
public

final

class
AutofillManager
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.autofill.AutofillManager |

<br />

*** ** * ** ***

<br />

The `https://developer.android.com/reference/android/view/autofill/AutofillManager` class provides ways for apps and custom views to
integrate with the Autofill Framework lifecycle.

To learn about using Autofill in your app, read
the [Autofill Framework](https://developer.android.com/guide/topics/text/autofill) guides.

### Autofill lifecycle

The autofill lifecycle starts with the creation of an autofill context associated with an
activity context. The autofill context is created when one of the following methods is called for
the first time in an activity context, and the current user has an enabled autofill service:

- `https://developer.android.com/reference/android/view/autofill/AutofillManager#notifyViewEntered(android.view.View)`
- `https://developer.android.com/reference/android/view/autofill/AutofillManager#notifyViewEntered(android.view.View,%20int,%20android.graphics.Rect)`
- `https://developer.android.com/reference/android/view/autofill/AutofillManager#requestAutofill(android.view.View)`

Typically, the context is automatically created when the first view of the activity is
focused because `View.onFocusChanged()` indirectly calls
`https://developer.android.com/reference/android/view/autofill/AutofillManager#notifyViewEntered(android.view.View)`. App developers can call `https://developer.android.com/reference/android/view/autofill/AutofillManager#requestAutofill(android.view.View)` to
explicitly create it (for example, a custom view developer could offer a contextual menu action
in a text-field view to let users manually request autofill).

After the context is created, the Android System creates a `https://developer.android.com/reference/android/view/ViewStructure`
that represents the view hierarchy by calling
`https://developer.android.com/reference/android/view/View#dispatchProvideAutofillStructure(android.view.ViewStructure,%20int)` in the root views
of all application windows. By default, `dispatchProvideAutofillStructure()` results in
subsequent calls to `https://developer.android.com/reference/android/view/View#onProvideAutofillStructure(android.view.ViewStructure,%20int)` and
`https://developer.android.com/reference/android/view/View#onProvideAutofillVirtualStructure(android.view.ViewStructure,%20int)` for each view in
the hierarchy.

The resulting `https://developer.android.com/reference/android/view/ViewStructure` is then passed to the autofill service, which
parses it looking for views that can be autofilled. If the service finds such views, it returns
a data structure to the Android System containing the following optional info:

- Datasets used to autofill subsets of views in the activity.
- Id of views that the service can save their values for future autofilling.

When the service returns datasets, the Android System displays an autofill dataset picker
UI associated with the view, when the view is focused on and is part of a dataset.
The application can be notified when the UI is shown by registering an
`https://developer.android.com/reference/android/view/autofill/AutofillManager.AutofillCallback` through `https://developer.android.com/reference/android/view/autofill/AutofillManager#registerCallback(android.view.autofill.AutofillManager.AutofillCallback)`. When the user
selects a dataset from the UI, all views present in the dataset are autofilled, through
calls to `https://developer.android.com/reference/android/view/View#autofill(android.view.autofill.AutofillValue)` or `https://developer.android.com/reference/android/view/View#autofill(android.util.SparseArray<android.view.autofill.AutofillValue>)`.

When the service returns ids of savable views, the Android System keeps track of changes
made to these views, so they can be used to determine if the autofill save UI is shown later.

The context is then finished when one of the following occurs:

- `https://developer.android.com/reference/android/view/autofill/AutofillManager#commit()` is called or all savable views are gone.
- `https://developer.android.com/reference/android/view/autofill/AutofillManager#cancel()` is called.

Finally, after the autofill context is commited (i.e., not cancelled), the Android System
shows an autofill save UI if the value of savable views have changed. If the user selects the
option to Save, the current value of the views is then sent to the autofill service.

### Additional notes

It is safe to call `AutofillManager` methods from any thread.


Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_AUTOFILL` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`.

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/view/autofill/AutofillManager.AutofillCallback` Callback for autofill related events. |

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/autofill/AutofillManager#EXTRA_ASSIST_STRUCTURE` Intent extra: The assist structure which captures the filled screen. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/autofill/AutofillManager#EXTRA_AUTHENTICATION_RESULT` Intent extra: The result of an authentication operation. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/autofill/AutofillManager#EXTRA_AUTHENTICATION_RESULT_EPHEMERAL_DATASET` Intent extra: The optional boolean extra field provided by the `https://developer.android.com/reference/android/service/autofill/AutofillService` accompanying the `https://developer.android.com/reference/android/service/autofill/Dataset` result of an authentication operation. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/autofill/AutofillManager#EXTRA_CLIENT_STATE` Intent extra: The optional extras provided by the `https://developer.android.com/reference/android/service/autofill/AutofillService`. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/view/autofill/AutofillManager#EXTRA_INLINE_SUGGESTIONS_REQUEST` Intent extra: the `https://developer.android.com/reference/android/view/inputmethod/InlineSuggestionsRequest` in the autofill request. |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#cancel()() ` Called to indicate the current autofill context should be cancelled. |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#commit()() ` Called to indicate the current autofill context should be commited. |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#disableAutofillServices()() ` If the app calling this API has enabled autofill services they will be disabled. |
| ` https://developer.android.com/reference/android/content/ComponentName` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#getAutofillServiceComponentName()() ` Returns the component name of the `https://developer.android.com/reference/android/service/autofill/AutofillService` that is enabled for the current user. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/String>` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#getAvailableFieldClassificationAlgorithms()() ` Gets the name of all algorithms currently available for [field classification](https://developer.android.com/reference/android/view/autofill/AutofillService#FieldClassification). |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#getDefaultFieldClassificationAlgorithm()() ` Gets the name of the default algorithm used for [field classification](https://developer.android.com/reference/android/view/autofill/AutofillService#FieldClassification). |
| ` https://developer.android.com/reference/android/view/autofill/AutofillId` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#getNextAutofillId()() ` Gets the next unique autofill ID for the activity context. |
| ` https://developer.android.com/reference/android/service/autofill/UserData` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#getUserData()() ` Gets the user data used for [field classification](https://developer.android.com/reference/android/view/autofill/AutofillService#FieldClassification). |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#getUserDataId()() ` Gets the id of the `https://developer.android.com/reference/android/service/autofill/UserData` used for [field classification](https://developer.android.com/reference/android/view/autofill/AutofillService#FieldClassification). |
| ` boolean` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#hasEnabledAutofillServices()() ` Returns `true` if the calling application provides a `https://developer.android.com/reference/android/service/autofill/AutofillService` that is enabled for the current user, or `false` otherwise. |
| ` boolean` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#isAutofillSupported()() ` Returns `true` if autofill is supported by the current device and is supported for this user. |
| ` boolean` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#isEnabled()() ` Checks whether autofill is enabled for the current user. |
| ` boolean` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#isFieldClassificationEnabled()() ` Checks if [field classification](https://developer.android.com/reference/android/view/autofill/AutofillService#FieldClassification) is enabled. |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#notifyValueChanged(android.view.View)(https://developer.android.com/reference/android/view/View view) ` Called to indicate the value of an autofillable `https://developer.android.com/reference/android/view/View` changed. |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#notifyValueChanged(android.view.View,%20int,%20android.view.autofill.AutofillValue)(https://developer.android.com/reference/android/view/View view, int virtualId, https://developer.android.com/reference/android/view/autofill/AutofillValue value) ` Called to indicate the value of an autofillable virtual view has changed. |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#notifyViewClicked(android.view.View)(https://developer.android.com/reference/android/view/View view) ` Called to indicate a `https://developer.android.com/reference/android/view/View` is clicked. |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#notifyViewClicked(android.view.View,%20int)(https://developer.android.com/reference/android/view/View view, int virtualId) ` Called to indicate a virtual view has been clicked. |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#notifyViewEntered(android.view.View)(https://developer.android.com/reference/android/view/View view) ` Called when a `https://developer.android.com/reference/android/view/View` that supports autofill is entered. |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#notifyViewEntered(android.view.View,%20int,%20android.graphics.Rect)(https://developer.android.com/reference/android/view/View view, int virtualId, https://developer.android.com/reference/android/graphics/Rect absBounds) ` Called when a virtual view that supports autofill is entered. |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#notifyViewExited(android.view.View,%20int)(https://developer.android.com/reference/android/view/View view, int virtualId) ` Called when a virtual view that supports autofill is exited. |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#notifyViewExited(android.view.View)(https://developer.android.com/reference/android/view/View view) ` Called when a `https://developer.android.com/reference/android/view/View` that supports autofill is exited. |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#notifyViewVisibilityChanged(android.view.View,%20int,%20boolean)(https://developer.android.com/reference/android/view/View view, int virtualId, boolean isVisible) ` Called when a virtual view's visibility changed. |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#notifyViewVisibilityChanged(android.view.View,%20boolean)(https://developer.android.com/reference/android/view/View view, boolean isVisible) ` Called when a `https://developer.android.com/reference/android/view/View` visibility changed. |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#notifyVirtualViewsReady(android.view.View,%20android.util.SparseArray<android.view.autofill.VirtualViewFillInfo>)(https://developer.android.com/reference/android/view/View view, https://developer.android.com/reference/android/util/SparseArray<https://developer.android.com/reference/android/view/autofill/VirtualViewFillInfo> infos) ` *This method was deprecated in API level 36. This function will not do anything. Showing fill dialog is now fully controlled by the framework and the autofill provider.* |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#registerCallback(android.view.autofill.AutofillManager.AutofillCallback)(https://developer.android.com/reference/android/view/autofill/AutofillManager.AutofillCallback callback) ` Registers a `https://developer.android.com/reference/android/view/autofill/AutofillManager.AutofillCallback` to receive autofill events. |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#requestAutofill(android.view.View,%20int,%20android.graphics.Rect)(https://developer.android.com/reference/android/view/View view, int virtualId, https://developer.android.com/reference/android/graphics/Rect absBounds) ` Explicitly requests a new autofill context for virtual views. |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#requestAutofill(android.view.View)(https://developer.android.com/reference/android/view/View view) ` Explicitly requests a new autofill context. |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#setUserData(android.service.autofill.UserData)(https://developer.android.com/reference/android/service/autofill/UserData userData) ` Sets the `https://developer.android.com/reference/android/service/autofill/UserData` used for [field classification](https://developer.android.com/reference/android/view/autofill/AutofillService#FieldClassification) **Note:** This method should only be called by an app providing an autofill service, and it's ignored if the caller currently doesn't have an enabled autofill service for the user. |
| ` boolean` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#showAutofillDialog(android.view.View,%20int)(https://developer.android.com/reference/android/view/View view, int virtualId) ` *This method was deprecated in API level 36. This function will not do anything. Showing fill dialog is now fully controlled by the framework and the autofill provider.* |
| ` boolean` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#showAutofillDialog(android.view.View)(https://developer.android.com/reference/android/view/View view) ` *This method was deprecated in API level 36. This function will not do anything. Showing fill dialog is now fully controlled by the framework and the autofill provider.* |
| ` void` | ` https://developer.android.com/reference/android/view/autofill/AutofillManager#unregisterCallback(android.view.autofill.AutofillManager.AutofillCallback)(https://developer.android.com/reference/android/view/autofill/AutofillManager.AutofillCallback callback) ` Unregisters a `https://developer.android.com/reference/android/view/autofill/AutofillManager.AutofillCallback` to receive autofill events. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Constants

### EXTRA_ASSIST_STRUCTURE

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

```
public static final String EXTRA_ASSIST_STRUCTURE
```

Intent extra: The assist structure which captures the filled screen.


Type: `https://developer.android.com/reference/android/app/assist/AssistStructure`

<br />

Constant Value:

"android.view.autofill.extra.ASSIST_STRUCTURE"


### EXTRA_AUTHENTICATION_RESULT

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

```
public static final String EXTRA_AUTHENTICATION_RESULT
```

Intent extra: The result of an authentication operation. It is
either a fully populated `https://developer.android.com/reference/android/service/autofill/FillResponse`
or a fully populated `https://developer.android.com/reference/android/service/autofill/Dataset` if
a response or a dataset is being authenticated respectively.


Type: `https://developer.android.com/reference/android/service/autofill/FillResponse` or a
`https://developer.android.com/reference/android/service/autofill/Dataset`

<br />

Constant Value:

"android.view.autofill.extra.AUTHENTICATION_RESULT"


### EXTRA_AUTHENTICATION_RESULT_EPHEMERAL_DATASET

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

```
public static final String EXTRA_AUTHENTICATION_RESULT_EPHEMERAL_DATASET
```

Intent extra: The optional boolean extra field provided by the
`https://developer.android.com/reference/android/service/autofill/AutofillService` accompanying the `https://developer.android.com/reference/android/service/autofill/Dataset` result of an authentication operation.

Before `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R`, if the authentication result is a
`https://developer.android.com/reference/android/service/autofill/Dataset`, it'll be used to autofill the fields, and also
replace the existing dataset in the cached `https://developer.android.com/reference/android/service/autofill/FillResponse`.
That means if the user clears the field values, the autofill suggestion will show up again
with the new authenticated Dataset.

In `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R`, we added an exception to this behavior
that if the Dataset being authenticated is a pinned dataset (see
`https://developer.android.com/reference/android/service/autofill/InlinePresentation#isPinned()`), the old Dataset will not be
replaced.

In `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S`, we added this boolean extra field to
allow the `https://developer.android.com/reference/android/service/autofill/AutofillService` to explicitly specify whether
the returned authenticated Dataset is ephemeral. An ephemeral Dataset will be used to
autofill once and then thrown away. Therefore, when the boolean extra is set to true, the
returned Dataset will not replace the old dataset from the existing
`https://developer.android.com/reference/android/service/autofill/FillResponse`. When it's set to false, it will. When it's not
set, the old dataset will be replaced, unless it is a pinned inline suggestion, which is
consistent with the behavior in `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R`.

<br />

Constant Value:

"android.view.autofill.extra.AUTHENTICATION_RESULT_EPHEMERAL_DATASET"


### EXTRA_CLIENT_STATE

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

```
public static final String EXTRA_CLIENT_STATE
```

Intent extra: The optional extras provided by the
`https://developer.android.com/reference/android/service/autofill/AutofillService`.

For example, when the service responds to a `https://developer.android.com/reference/android/service/autofill/FillCallback#onSuccess(android.service.autofill.FillResponse)` with
a `FillResponse` that requires authentication, the Intent that launches the
service authentication will contain the Bundle set by
`https://developer.android.com/reference/android/service/autofill/FillResponse.Builder#setClientState(android.os.Bundle)` on this extra.

On Android `https://developer.android.com/reference/android/os/Build.VERSION_CODES#P` and higher, the autofill service
can also add this bundle to the `https://developer.android.com/reference/android/content/Intent` set as the
`https://developer.android.com/reference/android/app/Activity#setResult(int,%20android.content.Intent)` for an authentication request,
so the bundle can be recovered later on
`https://developer.android.com/reference/android/service/autofill/SaveRequest#getClientState()`.


Type: `https://developer.android.com/reference/android/os/Bundle`

<br />

Constant Value:

"android.view.autofill.extra.CLIENT_STATE"


### EXTRA_INLINE_SUGGESTIONS_REQUEST

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

```
public static final String EXTRA_INLINE_SUGGESTIONS_REQUEST
```

Intent extra: the `https://developer.android.com/reference/android/view/inputmethod/InlineSuggestionsRequest` in the
autofill request.

This is filled in the authentication intent so the
`https://developer.android.com/reference/android/service/autofill/AutofillService` can use it to create the inline
suggestion `https://developer.android.com/reference/android/service/autofill/Dataset` in the response, if the original autofill
request contains the `https://developer.android.com/reference/android/view/inputmethod/InlineSuggestionsRequest`.

<br />

Constant Value:

"android.view.autofill.extra.INLINE_SUGGESTIONS_REQUEST"


## Public methods

### cancel

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

```
public void cancel ()
```

Called to indicate the current autofill context should be cancelled.

This method is typically called by `https://developer.android.com/reference/android/view/View` that manage virtual views; for
example, when the view is rendering an `HTML` page with a form and virtual views
that represent the HTML elements, it should call this method if the user does not post the
form but moves to another form in this page.

**Note:** This method does not need to be called on regular application lifecycle
methods such as `https://developer.android.com/reference/android/app/Activity#finish()`.

<br />

### commit

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

```
public void commit ()
```

Called to indicate the current autofill context should be commited.

This method is typically called by `https://developer.android.com/reference/android/view/View` that manage virtual views; for
example, when the view is rendering an `HTML` page with a form and virtual views
that represent the HTML elements, it should call this method after the form is submitted and
another page is rendered.

**Note:** This method does not need to be called on regular application lifecycle
methods such as `https://developer.android.com/reference/android/app/Activity#finish()`.

<br />

### disableAutofillServices

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

```
public void disableAutofillServices ()
```

If the app calling this API has enabled autofill services they
will be disabled.

<br />

### getAutofillServiceComponentName

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

```
public ComponentName getAutofillServiceComponentName ()
```

Returns the component name of the `https://developer.android.com/reference/android/service/autofill/AutofillService` that is enabled for the current
user.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ComponentName` | This value may be `null`. <br /> |

### getAvailableFieldClassificationAlgorithms

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

```
public List<String> getAvailableFieldClassificationAlgorithms ()
```

Gets the name of all algorithms currently available for
[field classification](https://developer.android.com/reference/android/view/autofill/AutofillService#FieldClassification).

**Note:** This method should only be called by an app providing an autofill service,
and it returns an empty list if the caller currently doesn't have an enabled autofill service
for the user.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/String>` | This value cannot be `null`. <br /> |

### getDefaultFieldClassificationAlgorithm

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

```
public String getDefaultFieldClassificationAlgorithm ()
```

Gets the name of the default algorithm used for
[field classification](https://developer.android.com/reference/android/view/autofill/AutofillService#FieldClassification).

The default algorithm is used when the algorithm on `https://developer.android.com/reference/android/service/autofill/UserData` is invalid or not
set.

**Note:** This method should only be called by an app providing an autofill service,
and it's ignored if the caller currently doesn't have an enabled autofill service for
the user.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | This value may be `null`. <br /> |

### getNextAutofillId

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

```
public AutofillId getNextAutofillId ()
```

Gets the next unique autofill ID for the activity context.

Typically used to manage views whose content is recycled - see
`https://developer.android.com/reference/android/view/View#setAutofillId(android.view.autofill.AutofillId)` for more info.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/autofill/AutofillId` | An ID that is unique in the activity, or `null` if autofill is not supported in the `https://developer.android.com/reference/android/content/Context` associated with this `https://developer.android.com/reference/android/view/autofill/AutofillManager`. <br /> |

### getUserData

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

```
public UserData getUserData ()
```

Gets the user data used for
[field classification](https://developer.android.com/reference/android/view/autofill/AutofillService#FieldClassification).

**Note:** This method should only be called by an app providing an autofill service,
and it's ignored if the caller currently doesn't have an enabled autofill service for
the user.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/autofill/UserData` | value previously set by `https://developer.android.com/reference/android/view/autofill/AutofillManager#setUserData(android.service.autofill.UserData)` or `null` if it was reset or if the caller currently does not have an enabled autofill service for the user. <br /> |

### getUserDataId

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

```
public String getUserDataId ()
```

Gets the id of the `https://developer.android.com/reference/android/service/autofill/UserData` used for
[field classification](https://developer.android.com/reference/android/view/autofill/AutofillService#FieldClassification).

This method is useful when the service must check the status of the `https://developer.android.com/reference/android/service/autofill/UserData` in
the device without fetching the whole object.

**Note:** This method should only be called by an app providing an autofill service,
and it's ignored if the caller currently doesn't have an enabled autofill service for
the user.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | id of the `https://developer.android.com/reference/android/service/autofill/UserData` previously set by `https://developer.android.com/reference/android/view/autofill/AutofillManager#setUserData(android.service.autofill.UserData)` or `null` if it was reset or if the caller currently does not have an enabled autofill service for the user. <br /> |

### hasEnabledAutofillServices

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

```
public boolean hasEnabledAutofillServices ()
```

Returns `true` if the calling application provides a `https://developer.android.com/reference/android/service/autofill/AutofillService` that is
enabled for the current user, or `false` otherwise.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isAutofillSupported

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

```
public boolean isAutofillSupported ()
```

Returns `true` if autofill is supported by the current device and
is supported for this user.

Autofill is typically supported, but it could be unsupported in cases like:

1. Low-end devices.
2. Device policy rules that forbid its usage.

<br />

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isEnabled

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

```
public boolean isEnabled ()
```

Checks whether autofill is enabled for the current user.

Typically used to determine whether the option to explicitly request autofill should
be offered - see `https://developer.android.com/reference/android/view/autofill/AutofillManager#requestAutofill(android.view.View)`.

<br />

| Returns ||
|---|---|
| `boolean` | whether autofill is enabled for the current user. <br /> |

### isFieldClassificationEnabled

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

```
public boolean isFieldClassificationEnabled ()
```

Checks if [field classification](https://developer.android.com/reference/android/view/autofill/AutofillService#FieldClassification) is
enabled.

As field classification is an expensive operation, it could be disabled, either
temporarily (for example, because the service exceeded a rate-limit threshold) or
permanently (for example, because the device is a low-level device).

**Note:** This method should only be called by an app providing an autofill service,
and it's ignored if the caller currently doesn't have an enabled autofill service for
the user.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### notifyValueChanged

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

```
public void notifyValueChanged (View view)
```

Called to indicate the value of an autofillable `https://developer.android.com/reference/android/view/View` changed.

<br />

| Parameters ||
|---|---|
| `view` | `View`: view whose value changed. <br /> |

### notifyValueChanged

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

```
public void notifyValueChanged (View view, 
                int virtualId, 
                AutofillValue value)
```

Called to indicate the value of an autofillable virtual view has changed.

<br />

| Parameters ||
|---|---|
| `view` | `View`: the virtual view parent. <br /> |
| `virtualId` | `int`: id identifying the virtual child inside the parent view. <br /> |
| `value` | `AutofillValue`: new value of the child. <br /> |

### notifyViewClicked

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

```
public void notifyViewClicked (View view)
```

Called to indicate a `https://developer.android.com/reference/android/view/View` is clicked.

<br />

| Parameters ||
|---|---|
| `view` | `View`: view that has been clicked. This value cannot be `null`. <br /> |

### notifyViewClicked

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

```
public void notifyViewClicked (View view, 
                int virtualId)
```

Called to indicate a virtual view has been clicked.

<br />

| Parameters ||
|---|---|
| `view` | `View`: the virtual view parent. This value cannot be `null`. <br /> |
| `virtualId` | `int`: id identifying the virtual child inside the parent view. <br /> |

### notifyViewEntered

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

```
public void notifyViewEntered (View view)
```

Called when a `https://developer.android.com/reference/android/view/View` that supports autofill is entered.

<br />

| Parameters ||
|---|---|
| `view` | `View`: `https://developer.android.com/reference/android/view/View` that was entered. This value cannot be `null`. <br /> |

### notifyViewEntered

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

```
public void notifyViewEntered (View view, 
                int virtualId, 
                Rect absBounds)
```

Called when a virtual view that supports autofill is entered.

The virtual view boundaries must be absolute screen coordinates. For example, if the
parent, non-virtual view uses `bounds` to draw the virtual view inside its Canvas,
the absolute bounds could be calculated by:

```text
   int offset[] = new int[2];
   getLocationOnScreen(offset);
   Rect absBounds = new Rect(bounds.left + offset[0],
       bounds.top + offset[1],
       bounds.right + offset[0], bounds.bottom + offset[1]);
 
```

<br />

<br />

| Parameters ||
|---|---|
| `view` | `View`: the virtual view parent. This value cannot be `null`. <br /> |
| `virtualId` | `int`: id identifying the virtual child inside the parent view. <br /> |
| `absBounds` | `Rect`: absolute boundaries of the virtual view in the screen. This value cannot be `null`. <br /> |

### notifyViewExited

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

```
public void notifyViewExited (View view, 
                int virtualId)
```

Called when a virtual view that supports autofill is exited.

<br />

| Parameters ||
|---|---|
| `view` | `View`: the virtual view parent. This value cannot be `null`. <br /> |
| `virtualId` | `int`: id identifying the virtual child inside the parent view. <br /> |

### notifyViewExited

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

```
public void notifyViewExited (View view)
```

Called when a `https://developer.android.com/reference/android/view/View` that supports autofill is exited.

<br />

| Parameters ||
|---|---|
| `view` | `View`: `https://developer.android.com/reference/android/view/View` that was exited. This value cannot be `null`. <br /> |

### notifyViewVisibilityChanged

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

```
public void notifyViewVisibilityChanged (View view, 
                int virtualId, 
                boolean isVisible)
```

Called when a virtual view's visibility changed.

<br />

| Parameters ||
|---|---|
| `view` | `View`: `https://developer.android.com/reference/android/view/View` that was exited. This value cannot be `null`. <br /> |
| `virtualId` | `int`: id identifying the virtual child inside the parent view. <br /> |
| `isVisible` | `boolean`: visible if the view is visible in the view hierarchy. <br /> |

### notifyViewVisibilityChanged

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

```
public void notifyViewVisibilityChanged (View view, 
                boolean isVisible)
```

Called when a `https://developer.android.com/reference/android/view/View` visibility changed.

<br />

| Parameters ||
|---|---|
| `view` | `View`: `https://developer.android.com/reference/android/view/View` that was exited. This value cannot be `null`. <br /> |
| `isVisible` | `boolean`: visible if the view is visible in the view hierarchy. <br /> |

### notifyVirtualViewsReady

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

```
public void notifyVirtualViewsReady (View view, 
                SparseArray<VirtualViewFillInfo> infos)
```


**This method was deprecated
in API level 36.**   

This function will not do anything. Showing fill dialog is now fully controlled
by the framework and the autofill provider.

Called when the virtual views are ready to the user for autofill.

This method is used to notify autofill system the views are ready to the user. And then
Autofill can do initialization if needed before the user starts to input. For example, do
a pre-fill request for the
[fill dialog](https://developer.android.com/reference/android/service/autofill/Dataset#FillDialogUI).

<br />

| Parameters ||
|---|---|
| `view` | `View`: the host view that holds a virtual view hierarchy. This value cannot be `null`. <br /> |
| `infos` | `SparseArray`: extra information for the virtual views. The key is virtual id which represents the virtual view in the host view. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the `infos` was empty |

### registerCallback

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

```
public void registerCallback (AutofillManager.AutofillCallback callback)
```

Registers a `https://developer.android.com/reference/android/view/autofill/AutofillManager.AutofillCallback` to receive autofill events.

<br />

| Parameters ||
|---|---|
| `callback` | `AutofillManager.AutofillCallback`: callback to receive events. This value may be `null`. <br /> |

### requestAutofill

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

```
public void requestAutofill (View view, 
                int virtualId, 
                Rect absBounds)
```

Explicitly requests a new autofill context for virtual views.

Normally, the autofill context is automatically started if necessary when
`https://developer.android.com/reference/android/view/autofill/AutofillManager#notifyViewEntered(android.view.View,%20int,%20android.graphics.Rect)` is called, but this method should be used in the
cases where it must be explicitly started. For example, when the virtual view offers an
AUTOFILL option on its contextual overflow menu, and the user selects it.

The virtual view boundaries must be absolute screen coordinates. For example, if the
parent view uses `bounds` to draw the virtual view inside its Canvas,
the absolute bounds could be calculated by:

```text
   int offset[] = new int[2];
   getLocationOnScreen(offset);
   Rect absBounds = new Rect(bounds.left + offset[0],
       bounds.top + offset[1],
       bounds.right + offset[0], bounds.bottom + offset[1]);
 
```

<br />

<br />

| Parameters ||
|---|---|
| `view` | `View`: the virtual view parent. This value cannot be `null`. <br /> |
| `virtualId` | `int`: id identifying the virtual child inside the parent view. <br /> |
| `absBounds` | `Rect`: absolute boundaries of the virtual view in the screen. This value cannot be `null`. <br /> |

### requestAutofill

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

```
public void requestAutofill (View view)
```

Explicitly requests a new autofill context.

Normally, the autofill context is automatically started if necessary when
`https://developer.android.com/reference/android/view/autofill/AutofillManager#notifyViewEntered(android.view.View)` is called, but this method should be used in the
cases where it must be explicitly started. For example, when the view offers an AUTOFILL
option on its contextual overflow menu, and the user selects it.

<br />

| Parameters ||
|---|---|
| `view` | `View`: view requesting the new autofill context. This value cannot be `null`. <br /> |

### setUserData

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

```
public void setUserData (UserData userData)
```

Sets the `https://developer.android.com/reference/android/service/autofill/UserData` used for
[field classification](https://developer.android.com/reference/android/view/autofill/AutofillService#FieldClassification)

**Note:** This method should only be called by an app providing an autofill service,
and it's ignored if the caller currently doesn't have an enabled autofill service for
the user.

<br />

| Parameters ||
|---|---|
| `userData` | `UserData`: This value may be `null`. <br /> |

### showAutofillDialog

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

```
public boolean showAutofillDialog (View view, 
                int virtualId)
```


**This method was deprecated
in API level 36.**   

This function will not do anything. Showing fill dialog is now fully controlled
by the framework and the autofill provider.

If autofill suggestions for a
[dialog-style UI](https://developer.android.com/reference/android/service/autofill/Dataset#FillDialogUI) are available for virtual `view`, shows a dialog allowing the user
to select a suggestion and returns `true`.


The dialog may not be shown if the autofill service does not support it, if the autofill
request has not returned a response yet, if the dialog was shown previously, or if the
input method is already shown.


It is recommended apps to call this method the first time a user focuses on
an autofill-able form, and to avoid showing the input method if the dialog is shown. If
this method returns `false`, you should then instead show the input method (assuming
that is how the view normally handles the focus event). If the user re-focuses on the view,
you should not call this method again so as to not disrupt usage of the input method.

<br />

| Parameters ||
|---|---|
| `view` | `View`: the view hosting the virtual view hierarchy which is used to show autofill suggestions. This value cannot be `null`. <br /> |
| `virtualId` | `int`: id identifying the virtual view inside the host view. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the autofill dialog is being shown <br /> |

### showAutofillDialog

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

```
public boolean showAutofillDialog (View view)
```


**This method was deprecated
in API level 36.**   

This function will not do anything. Showing fill dialog is now fully controlled
by the framework and the autofill provider.

If autofill suggestions for a
[dialog-style UI](https://developer.android.com/reference/android/service/autofill/Dataset#FillDialogUI) are available for `view`, shows a dialog allowing the user to
select a suggestion and returns `true`.


The dialog may not be shown if the autofill service does not support it, if the autofill
request has not returned a response yet, if the dialog was shown previously, or if the
input method is already shown.


It is recommended apps to call this method the first time a user focuses on
an autofill-able form, and to avoid showing the input method if the dialog is shown. If
this method returns `false`, you should then instead show the input method (assuming
that is how the view normally handles the focus event). If the user re-focuses on the view,
you should not call this method again so as to not disrupt usage of the input method.

<br />

| Parameters ||
|---|---|
| `view` | `View`: the view for which to show autofill suggestions. This is typically a view receiving a focus event. The autofill suggestions shown will include content for related views as well. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the autofill dialog is being shown <br /> |

### unregisterCallback

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

```
public void unregisterCallback (AutofillManager.AutofillCallback callback)
```

Unregisters a `https://developer.android.com/reference/android/view/autofill/AutofillManager.AutofillCallback` to receive autofill events.

<br />

| Parameters ||
|---|---|
| `callback` | `AutofillManager.AutofillCallback`: callback to stop receiving events. This value may be `null`. <br /> |