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 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 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 Toast.

Parameters
message CharSequence: error message. Note: this message should not contain PII (Personally Identifiable Information, such as username or email address).

Throws
IllegalStateException if this method, onSuccess(), or onSuccess(android.content.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 cannot be null.

Throws
IllegalStateException if this method, onSuccess(), or onFailure(java.lang.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(android.content.IntentSender), or onFailure(java.lang.CharSequence) was already called.