Skip to content

Most visited

Recently visited

navigation

FillResponse

public final class FillResponse
extends Object implements Parcelable

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


Response for a onFillRequest(FillRequest, android.os.CancellationSignal, FillCallback).

The response typically contains one or more Datasets, each representing a set of fields that can be autofilled together, and the Android system displays a dataset picker UI affordance that the user must use before the Activity is filled with the dataset.

For example, for a login page with username/password where the user only has one account in the response could be:

  new FillResponse.Builder()
      .add(new Dataset.Builder(createPresentation())
          .setValue(id1, AutofillValue.forText("homer"))
          .setValue(id2, AutofillValue.forText("D'OH!"))
          .build())
      .build();
 

If the user had 2 accounts, each with its own user-provided names, the response could be:

  new FillResponse.Builder()
      .add(new Dataset.Builder(createFirstPresentation())
          .setValue(id1, AutofillValue.forText("homer"))
          .setValue(id2, AutofillValue.forText("D'OH!"))
          .build())
      .add(new Dataset.Builder(createSecondPresentation())
          .setValue(id1, AutofillValue.forText("elbarto")
          .setValue(id2, AutofillValue.forText("cowabonga")
          .build())
      .build();
 
If the service is interested on saving the user-edited data back, it must set a SaveInfo in the FillResponse. Typically, the SaveInfo contains the same ids as the Dataset, but other combinations are possible - see SaveInfo for more details

If the service has multiple Datasets for different sections of the activity, for example, a user section for which there are two datasets followed by an address section for which there are two datasets for each user user, then it should "partition" the activity in sections and populate the response with just a subset of the data that would fulfill the first section (the name in our example); then once the user fills the first section and taps a field from the next section (the address in our example), the Android system would issue another request for that section, and so on. Note that if the user chooses to populate the first section with a service provided dataset, the subsequent request would contain the populated values so you don't try to provide suggestions for the first section but ony for the second one based on the context of what was already filled. For example, the first response could be:

  new FillResponse.Builder()
      .add(new Dataset.Builder(createFirstPresentation())
          .setValue(id1, AutofillValue.forText("Homer"))
          .setValue(id2, AutofillValue.forText("Simpson"))
          .build())
      .add(new Dataset.Builder(createSecondPresentation())
          .setValue(id1, AutofillValue.forText("Bart"))
          .setValue(id2, AutofillValue.forText("Simpson"))
          .build())
      .build();
 

Then after the user picks the second dataset and taps the street field to trigger another autofill request, the second response could be:

  new FillResponse.Builder()
      .add(new Dataset.Builder(createThirdPresentation())
          .setValue(id3, AutofillValue.forText("742 Evergreen Terrace"))
          .setValue(id4, AutofillValue.forText("Springfield"))
          .build())
      .add(new Dataset.Builder(createFourthPresentation())
          .setValue(id3, AutofillValue.forText("Springfield Power Plant"))
          .setValue(id4, AutofillValue.forText("Springfield"))
          .build())
      .build();
 

The service could require user authentication at the FillResponse or the Dataset level, prior to autofilling an activity - see setAuthentication(AutofillId[], IntentSender, RemoteViews) and setAuthentication(IntentSender).

It is recommended that you encrypt only the sensitive data but leave the labels unencrypted which would allow you to provide a dataset presentation views with labels and if the user chooses one of them challenge the user to authenticate. For example, if the user has a home and a work address the Home and Work labels could be stored unencrypted as they don't have any sensitive data while the address data is in an encrypted storage. If the user chooses Home, then the platform will start your authentication flow. If you encrypt all data and require auth at the response level the user will have to interact with the fill UI to trigger a request for the datasets (as they don't see the presentation views for the possible options) which will start your auth flow and after successfully authenticating the user will be presented with the Home and Work options to pick one. Hence, you have flexibility how to implement your auth while storing labels non-encrypted and data encrypted provides a better user experience.

Summary

Nested classes

class FillResponse.Builder

Builder for FillResponse objects. 

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<FillResponse> CREATOR

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel parcel, int flags)

Flatten this object in to a Parcel.

Inherited methods

From class java.lang.Object
From interface android.os.Parcelable

Fields

Public methods

describeContents

int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.

toString

String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.

writeToParcel

void writeToParcel (Parcel parcel, 
                int flags)

Flatten this object in to a Parcel.

Parameters
parcel Parcel: The Parcel in which the object should be written.

flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

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.