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/SaveCallback#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/service/autofill/SaveCallback#inhmethods)

# SaveCallback

*** ** * ** ***

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

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

<br />

*** ** * ** ***

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

## Summary

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/service/autofill/SaveCallback#onFailure(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence message) ` Notifies the Android System that an `https://developer.android.com/reference/android/service/autofill/AutofillService#onSaveRequest(android.service.autofill.SaveRequest,%20android.service.autofill.SaveCallback)` could not be handled by the service. |
| ` void` | ` https://developer.android.com/reference/android/service/autofill/SaveCallback#onSuccess(android.content.IntentSender)(https://developer.android.com/reference/android/content/IntentSender intentSender) ` Notifies the Android System that an `https://developer.android.com/reference/android/service/autofill/AutofillService#onSaveRequest(android.service.autofill.SaveRequest,%20android.service.autofill.SaveCallback)` was successfully handled by the service. |
| ` void` | ` https://developer.android.com/reference/android/service/autofill/SaveCallback#onSuccess()() ` Notifies the Android System that an `https://developer.android.com/reference/android/service/autofill/AutofillService#onSaveRequest(android.service.autofill.SaveRequest,%20android.service.autofill.SaveCallback)` was successfully handled 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 an `https://developer.android.com/reference/android/service/autofill/AutofillService#onSaveRequest(android.service.autofill.SaveRequest,%20android.service.autofill.SaveCallback)` could not be handled by the service.

This method is just used for logging purposes, the Android System won't call the service again in case of failures---if you need to recover from the failure, just save the `https://developer.android.com/reference/android/service/autofill/SaveRequest` and try again later.

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

<br />

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

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

### onSuccess

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

```
public void onSuccess (IntentSender intentSender)
```

Notifies the Android System that an `https://developer.android.com/reference/android/service/autofill/AutofillService#onSaveRequest(android.service.autofill.SaveRequest,%20android.service.autofill.SaveCallback)` was successfully handled by the service.

This method is useful when the service requires extra work---for example, launching an activity asking the user to authenticate first ---before it can process the request, as the intent will be launched from the context of the activity being autofilled and hence will be part of that activity's stack.

<br />

| Parameters ||
|---|---|
| `intentSender` | `IntentSender`: intent that will be launched from the context of activity being autofilled. This value cannot be `null`. <br /> |

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

### onSuccess

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

```
public void onSuccess ()
```

Notifies the Android System that an `https://developer.android.com/reference/android/service/autofill/AutofillService#onSaveRequest(android.service.autofill.SaveRequest,%20android.service.autofill.SaveCallback)` was successfully handled by the service.

<br />

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