Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/service/autofill/FillCallback#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/service/autofill/FillCallback#inhmethods)

# FillCallback

*** ** * ** ***

` public final class FillCallback `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

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

<br />

*** ** * ** ***

<br />

`FillCallback` handles autofill requests from the `https://developer.android.com/reference/android/service/autofill/AutofillService` into the `https://developer.android.com/reference/android/app/Activity` being autofilled.

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

## Summary

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/service/autofill/FillCallback#onFailure(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence message) ` Notifies the Android System that a fill request ( `https://developer.android.com/reference/android/service/autofill/AutofillService#onFillRequest(android.service.autofill.FillRequest,%20android.os.CancellationSignal,%20android.service.autofill.FillCallback)`) could not be fulfilled by the service (for example, because the user data was not available yet), so the request could be retried later. |
| ` void` | ` https://developer.android.com/reference/android/service/autofill/FillCallback#onSuccess(android.service.autofill.FillResponse)(https://developer.android.com/reference/android/service/autofill/FillResponse response) ` Notifies the Android System that a fill request (`https://developer.android.com/reference/android/service/autofill/AutofillService#onFillRequest(android.service.autofill.FillRequest,%20android.os.CancellationSignal,%20android.service.autofill.FillCallback)`) was successfully fulfilled by the service. |

### 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*.

## Public methods

### onFailure

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

```
public void onFailure (CharSequence message)
```

Notifies the Android System that a fill request ( `https://developer.android.com/reference/android/service/autofill/AutofillService#onFillRequest(android.service.autofill.FillRequest,%20android.os.CancellationSignal,%20android.service.autofill.FillCallback)`) could not be fulfilled by the service (for example, because the user data was not available yet), so the request could be retried later.

**Note:** this method should not be used when the service didn't have the heursitics to fulfill the request; in this case, the service should call `https://developer.android.com/reference/android/service/autofill/FillCallback#onSuccess(android.service.autofill.FillResponse)` instead.

**Note:** prior to `https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q`, this method was not working as intended and the service should always call `https://developer.android.com/reference/android/service/autofill/FillCallback#onSuccess(android.service.autofill.FillResponse)` instead.

**Note:** for apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q` or higher, this method just logs the message on `logcat`; for apps targetting older SDKs, it also displays the message to user using a `https://developer.android.com/reference/android/widget/Toast`. Generally speaking, you should not display an error to the user if the request failed, unless the request had the `https://developer.android.com/reference/android/service/autofill/FillRequest#FLAG_MANUAL_REQUEST` flag.

<br />

| Parameters ||
|---|---|
| `message` | `CharSequence`: error message. **Note:** this message should **not** contain PII (Personally Identifiable Information, such as username or email address). This value may be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if this method or `https://developer.android.com/reference/android/service/autofill/FillCallback#onSuccess(android.service.autofill.FillResponse)` was already called. |

### onSuccess

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

```
public void onSuccess (FillResponse response)
```

Notifies the Android System that a fill request (`https://developer.android.com/reference/android/service/autofill/AutofillService#onFillRequest(android.service.autofill.FillRequest,%20android.os.CancellationSignal,%20android.service.autofill.FillCallback)`) was successfully fulfilled by the service.

This method should always be called, even if the service doesn't have the heuristics to fulfill the request (in which case it should be called with `null`).

See the main `https://developer.android.com/reference/android/service/autofill/AutofillService` documentation for more details and examples.

<br />

| Parameters ||
|---|---|
| `response` | `FillResponse`: autofill information for that activity, or `null` when the service cannot autofill the activity. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if this method or `https://developer.android.com/reference/android/service/autofill/FillCallback#onFailure(java.lang.CharSequence)` was already called. |