Skip to content

Most visited

Recently visited

navigation

AutoFillService

public abstract class AutoFillService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.service.autofill.AutoFillService


Top-level service of the current auto-fill service for a given user.

Apps providing auto-fill capabilities must extend this service.

Summary

Constants

String SERVICE_INTERFACE

The Intent that must be declared as handled by the service.

String SERVICE_META_DATA

Name under which a AutoFillService component publishes information about itself.

Inherited constants

From class android.app.Service
From class android.content.Context
From interface android.content.ComponentCallbacks2

Public constructors

AutoFillService()

Public methods

final IBinder onBind(Intent intent)

Return the communication channel to the service.

void onConnected()

Called when the Android system connects to service.

void onCreate()

Called by the system when the service is first created. NOTE: if overridden, it must call super.onCreate().

void onDisconnected()

Called when the Android system disconnects from the service.

abstract void onFillRequest(AssistStructure structure, Bundle data, CancellationSignal cancellationSignal, FillCallback callback)

Called by the Android system do decide if an Activity can be auto-filled by the service.

abstract void onSaveRequest(AssistStructure structure, Bundle data, SaveCallback callback)

Called when user requests service to save the fields of an Activity.

Inherited methods

From class android.app.Service
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object
From interface android.content.ComponentCallbacks2
From interface android.content.ComponentCallbacks

Constants

SERVICE_INTERFACE

String SERVICE_INTERFACE

The Intent that must be declared as handled by the service. To be supported, the service must also require the BIND_AUTO_FILL permission so that other applications can not abuse it.

Constant Value: "android.service.autofill.AutoFillService"

SERVICE_META_DATA

String SERVICE_META_DATA

Name under which a AutoFillService component publishes information about itself. This meta-data should reference an XML resource containing a <autofill-service> tag. This is a a sample XML file configuring an AutoFillService:

 <autofill-service
     android:settingsActivity="foo.bar.SettingsActivity"
     . . .
 />

Constant Value: "android.autofill"

Public constructors

AutoFillService

AutoFillService ()

Public methods

onBind

IBinder onBind (Intent intent)

Return the communication channel to the service. May return null if clients can not bind to the service. The returned IBinder is usually for a complex interface that has been described using aidl.

Note that unlike other application components, calls on to the IBinder interface returned here may not happen on the main thread of the process. More information about the main thread can be found in Processes and Threads.

Parameters
intent Intent: The Intent that was used to bind to this service, as given to Context.bindService. Note that any extras that were included with the Intent at that point will not be seen here.
Returns
IBinder Return an IBinder through which clients can call on to the service.

onConnected

void onConnected ()

Called when the Android system connects to service.

You should generally do initialization here rather than in onCreate().

onCreate

void onCreate ()

Called by the system when the service is first created. Do not call this method directly. NOTE: if overridden, it must call super.onCreate().

onDisconnected

void onDisconnected ()

Called when the Android system disconnects from the service.

At this point this service may no longer be an active AutoFillService.

onFillRequest

void onFillRequest (AssistStructure structure, 
                Bundle data, 
                CancellationSignal cancellationSignal, 
                FillCallback callback)

Called by the Android system do decide if an Activity can be auto-filled by the service.

Service must call one of the FillCallback methods (like onSuccess(FillResponse) or onFailure(CharSequence)) to notify the result of the request.

Parameters
structure AssistStructure: Activity's view structure.
data Bundle: bundle containing data passed by the service on previous calls to fill. This bundle allows your service to keep state between fill and save requests as well as when filling different sections of the UI as the system will try to aggressively unbind from the service to conserve resources. See FillResponse Javadoc for examples of multiple-sections requests.
cancellationSignal CancellationSignal: signal for observing cancellation requests. The system will use this to notify you that the fill result is no longer needed and you should stop handling this fill request in order to save resources.
callback FillCallback: object used to notify the result of the request.

onSaveRequest

void onSaveRequest (AssistStructure structure, 
                Bundle data, 
                SaveCallback callback)

Called when user requests service to save the fields of an Activity.

Service must call one of the SaveCallback methods (like onSuccess() or onFailure(CharSequence)) to notify the result of the request.

Parameters
structure AssistStructure: Activity's view structure.
data Bundle: bundle containing data passed by the service on previous calls to fill. This bundle allows your service to keep state between fill and save requests as well as when filling different sections of the UI as the system will try to aggressively unbind from the service to conserve resources. See FillResponse Javadoc for examples of multiple-sections requests.
callback SaveCallback: object used to notify the result of the request.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.