Join us on the livestream at Android Dev Summit on 7-8 November 2018, starting at 10AM PDT!
added in API level 26

SaveCallback

public final class SaveCallback
extends Object

java.lang.Object
   ↳ android.service.autofill.SaveCallback


Handles save requests from the AutofillService into the Activity being autofilled.

Summary

Public methods

void onFailure(CharSequence message)

Notifies the Android System that an AutofillService.onSaveRequest(SaveRequest, SaveCallback) could not be handled by the service.

void onSuccess(IntentSender intentSender)

Notifies the Android System that an AutofillService.onSaveRequest(SaveRequest, SaveCallback) was successfully handled by the service.

void onSuccess()

Notifies the Android System that an AutofillService.onSaveRequest(SaveRequest, SaveCallback) was successfully handled by the service.

Inherited methods

Public methods

onFailure

added in API level 26
public void onFailure (CharSequence message)

Notifies the Android System that an AutofillService.onSaveRequest(SaveRequest, SaveCallback) could not be handled by the service.

This method should only be called when the service could not handle the request right away and could not recover or retry it. If the service could retry or recover, it could keep the SaveRequest and call onSuccess() instead.

Note: The Android System displays an UI with the supplied error message; if you prefer to show your own message, call onSuccess() or onSuccess(IntentSender) instead.

Parameters
message CharSequence: error message to be displayed to the user. Note: this message is displayed on logcat logs and should not contain PII (Personally Identifiable Information, such as username or email address).

Throws
IllegalStateException if this method, onSuccess(), or onSuccess(IntentSender) was already called.

onSuccess

added in API level 28
public void onSuccess (IntentSender intentSender)

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 must never be null.

Throws
IllegalStateException if this method, onSuccess(), or onFailure(CharSequence) was already called.

onSuccess

added in API level 26
public void onSuccess ()

Notifies the Android System that an AutofillService.onSaveRequest(SaveRequest, SaveCallback) was successfully handled by the service.

Throws
IllegalStateException if this method, onSuccess(IntentSender), or onFailure(CharSequence) was already called.