Stay organized with collections
Save and categorize content based on your preferences.
FillCallback
class FillCallback
FillCallback
handles autofill requests from the AutofillService
into the Activity
being autofilled.
To learn about using Autofill services in your app, read Build autofill services.
Summary
Public methods
onFailure
fun onFailure(message: CharSequence?): Unit
Notifies the Android System that a fill request ( AutofillService.onFillRequest(FillRequest, android.os.CancellationSignal,
) 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 onSuccess(null)
instead.
Note: prior to android.os.Build.VERSION_CODES#Q
, this method was not working as intended and the service should always call onSuccess(null)
instead.
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
. Generally speaking, you should not display an error to the user if the request failed, unless the request had the FillRequest.FLAG_MANUAL_REQUEST
flag.
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 . |
onSuccess
fun onSuccess(response: FillResponse?): Unit
Notifies the Android System that a fill request (AutofillService.onFillRequest(FillRequest, android.os.CancellationSignal,
) 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 AutofillService
documentation for more details and examples.
Parameters |
response |
FillResponse?: autofill information for that activity, or null when the service cannot autofill the activity. |
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,["# FillCallback\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nFillCallback\n============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/service/autofill/FillCallback \"View this page in Java\") \n\n```\nclass FillCallback\n```\n\n|---|--------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.service.autofill.FillCallback](#) |\n\n`FillCallback` handles autofill requests from the [AutofillService](/reference/kotlin/android/service/autofill/AutofillService) into the [Activity](../../app/Activity.html#) being autofilled.\n\nTo learn about using Autofill services in your app, read [Build autofill services](../../../guide/topics/text/autofill-services).\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 a fill request ( [AutofillService.onFillRequest(FillRequest, android.os.CancellationSignal,](/reference/kotlin/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. |\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onSuccess](#onSuccess(android.service.autofill.FillResponse))`(`response:` `[FillResponse](/reference/kotlin/android/service/autofill/FillResponse)?`)` Notifies the Android System that a fill request ([AutofillService.onFillRequest(FillRequest, android.os.CancellationSignal,](/reference/kotlin/android/service/autofill/AutofillService#onFillRequest(android.service.autofill.FillRequest,%20android.os.CancellationSignal,%20android.service.autofill.FillCallback))) was successfully fulfilled 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 a fill request ( [AutofillService.onFillRequest(FillRequest, android.os.CancellationSignal,](/reference/kotlin/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.\n\n**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 [onSuccess(null)](#onSuccess(android.service.autofill.FillResponse)) instead.\n\n**Note:** prior to [android.os.Build.VERSION_CODES#Q](../../os/Build.VERSION_CODES.html#Q:kotlin.Int), this method was not working as intended and the service should always call [onSuccess(null)](#onSuccess(android.service.autofill.FillResponse)) instead.\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#). Generally speaking, you should not display an error to the user if the request failed, unless the request had the [FillRequest.FLAG_MANUAL_REQUEST](/reference/kotlin/android/service/autofill/FillRequest#FLAG_MANUAL_REQUEST:kotlin.Int) flag.\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). This value may be `null`. |\n\n| Exceptions ||\n|-----------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|\n| `java.lang.IllegalStateException` | if this method or [onSuccess(android.service.autofill.FillResponse)](#onSuccess(android.service.autofill.FillResponse)) 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(response: FillResponse?): Unit\n```\n\nNotifies the Android System that a fill request ([AutofillService.onFillRequest(FillRequest, android.os.CancellationSignal,](/reference/kotlin/android/service/autofill/AutofillService#onFillRequest(android.service.autofill.FillRequest,%20android.os.CancellationSignal,%20android.service.autofill.FillCallback))) was successfully fulfilled by the service.\n\nThis 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`).\n\nSee the main [AutofillService](/reference/kotlin/android/service/autofill/AutofillService) documentation for more details and examples.\n\n| Parameters ||\n|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `response` | [FillResponse](/reference/kotlin/android/service/autofill/FillResponse)?: autofill information for that activity, or `null` when the service cannot autofill the activity. |\n\n| Exceptions ||\n|-----------------------------------|------------------------------------------------------------------------------------------------------------|\n| `java.lang.IllegalStateException` | if this method or [onFailure(java.lang.CharSequence)](#onFailure(kotlin.CharSequence)) was already called. |"]]