The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.

The Autofill API

Many Web browsers, such as Chrome, offer “autofill”. The browser remembers things that you have typed into certain fields, like addresses, and offers to fill those back in when you go to fill in the same form again… or even a different form with similar fields.

Android 8.0 adds autofill capability to Android via the Autofill Framework. Values that users enter into your forms will be remembered and offered again when the user returns to your form, or to other forms that they encounter in other apps on the device. This all happens without any changes to your code… in theory. In practice, you may need some changes to your code.

However, Android itself does not store the form data, nor offer it as suggestions for autofilling in a form. Android is merely serving as a conduit between your app and a third-party autofill service. It is the service that is responsible for determining what could be autofilled in your form and saving prior entries. As with the Assist API, the user can choose an autofill service, and none ship by default with the O Developer Preview. In all likelihood, a Google-branded autofill implementation will be part of the production rollout of Android 8.0, but the user could choose other autofill apps… or perhaps none at all, for privacy reasons.

In this chapter, we will explore the AutoFill API, in terms of:

NOTE: O Developer Preview 2 renamed many of the Autofill Framework classes and methods to make the f in Autofill lowercase. So, for example, AutoFillService became AutofillService. Materials written based on O Developer Preview 1 (blog posts, Stack Overflow answers, etc.) will have a capital F instead.


Understanding this chapter requires that you have read the core chapters of this book.

There are commonalities between autofill and the Assist API, and so this chapter will refer back to that one from time to time.

The Pieces of the Puzzle

The preview of this section apparently resembled a Pokémon.

The User Experience

The preview of this section was whisked away by a shark-infested tornado.

What Data Gets Disclosed

The preview of this section is being chased by zombies.

Blocking Autofill as a User

The preview of this section was whisked away by a shark-infested tornado.

Supporting Autofill with Standard Widgets

The preview of this section was abducted by space aliens.

Supporting Autofill with Custom Widgets

The preview of this section is being chased by zombies.

Dealing with Dynamic Changes

The preview of this section is en route to Mars.

Security Requirements of Autofill Services

The preview of this section is [REDACTED].