Stay organized with collections
Save and categorize content based on your preferences.
SaveCallback
class SaveCallback
Handles save requests from the AutofillService
into the Activity
being autofilled.
Summary
Public methods
onFailure
fun onFailure(message: CharSequence!): Unit
Notifies the Android System that an AutofillService.onSaveRequest(SaveRequest, 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 SaveRequest
and try again later.
Note: for apps targeting 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 android.widget.Toast
.
Parameters |
message |
CharSequence!: error message. Note: this message should not contain PII (Personally Identifiable Information, such as username or email address). |
onSuccess
fun onSuccess(intentSender: IntentSender): Unit
Notifies the Android System that an AutofillService.onSaveRequest(SaveRequest, 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.
Parameters |
intentSender |
IntentSender: intent that will be launched from the context of activity being autofilled. This value cannot be null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# SaveCallback\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nSaveCallback\n============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/service/autofill/SaveCallback \"View this page in Java\") \n\n```\nclass SaveCallback\n```\n\n|---|--------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.service.autofill.SaveCallback](#) |\n\nHandles save requests from the [AutofillService](/reference/kotlin/android/service/autofill/AutofillService) into the [Activity](../../app/Activity.html#) being autofilled.\n\nSummary\n-------\n\n| Public methods ||\n|------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onFailure](#onFailure(kotlin.CharSequence))`(`message:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!`)` Notifies the Android System that an [AutofillService.onSaveRequest(SaveRequest, SaveCallback)](/reference/kotlin/android/service/autofill/AutofillService#onSaveRequest(android.service.autofill.SaveRequest,%20android.service.autofill.SaveCallback)) could not be handled by the service. |\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onSuccess](#onSuccess())`()` Notifies the Android System that an [AutofillService.onSaveRequest(SaveRequest, SaveCallback)](/reference/kotlin/android/service/autofill/AutofillService#onSaveRequest(android.service.autofill.SaveRequest,%20android.service.autofill.SaveCallback)) was successfully handled by the service. |\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onSuccess](#onSuccess(android.content.IntentSender))`(`intentSender:` `[IntentSender](../../content/IntentSender.html#)`)` Notifies the Android System that an [AutofillService.onSaveRequest(SaveRequest, SaveCallback)](/reference/kotlin/android/service/autofill/AutofillService#onSaveRequest(android.service.autofill.SaveRequest,%20android.service.autofill.SaveCallback)) was successfully handled by the service. |\n\nPublic methods\n--------------\n\n### onFailure\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun onFailure(message: CharSequence!): Unit\n```\n\nNotifies the Android System that an [AutofillService.onSaveRequest(SaveRequest, SaveCallback)](/reference/kotlin/android/service/autofill/AutofillService#onSaveRequest(android.service.autofill.SaveRequest,%20android.service.autofill.SaveCallback)) could not be handled by the service.\n\nThis 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 [SaveRequest](/reference/kotlin/android/service/autofill/SaveRequest) and try again later.\n\n**Note:** for apps targeting [android.os.Build.VERSION_CODES#Q](../../os/Build.VERSION_CODES.html#Q:kotlin.Int) or higher, this method just logs the message on `logcat`; for apps targetting older SDKs, it also displays the message to user using a [android.widget.Toast](../../widget/Toast.html#).\n\n| Parameters ||\n|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `message` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!: error message. **Note:** this message should **not** contain PII (Personally Identifiable Information, such as username or email address). |\n\n| Exceptions ||\n|-----------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `java.lang.IllegalStateException` | if this method, [onSuccess()](#onSuccess()), or [onSuccess(android.content.IntentSender)](#onSuccess(android.content.IntentSender)) was already called. |\n\n### onSuccess\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun onSuccess(): Unit\n```\n\nNotifies the Android System that an [AutofillService.onSaveRequest(SaveRequest, SaveCallback)](/reference/kotlin/android/service/autofill/AutofillService#onSaveRequest(android.service.autofill.SaveRequest,%20android.service.autofill.SaveCallback)) was successfully handled by the service.\n\n| Exceptions ||\n|-----------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `java.lang.IllegalStateException` | if this method, [onSuccess(android.content.IntentSender)](#onSuccess(android.content.IntentSender)), or [onFailure(java.lang.CharSequence)](#onFailure(kotlin.CharSequence)) was already called. |\n\n### onSuccess\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun onSuccess(intentSender: IntentSender): Unit\n```\n\nNotifies the Android System that an [AutofillService.onSaveRequest(SaveRequest, SaveCallback)](/reference/kotlin/android/service/autofill/AutofillService#onSaveRequest(android.service.autofill.SaveRequest,%20android.service.autofill.SaveCallback)) was successfully handled by the service.\n\nThis 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.\n\n| Parameters ||\n|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `intentSender` | [IntentSender](../../content/IntentSender.html#): intent that will be launched from the context of activity being autofilled. This value cannot be `null`. |\n\n| Exceptions ||\n|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|\n| `java.lang.IllegalStateException` | if this method, [onSuccess()](#onSuccess()), or [onFailure(java.lang.CharSequence)](#onFailure(kotlin.CharSequence)) was already called. |"]]