The Autofill framework lets you create a service that provides information to data entry forms. The user can then select from the data to quickly fill in the form. I'll demonstrate this with a sample app provided by Google.
- [Narrator] Th autofill framework is another new tool in Android O, that's designed to make it easier for users to navigate Android apps. There's a sample app for this feature that you can download from the welcome screen. I'll import another Android code sample and this time I'll choose autofill framework under Android O preview and I'll download and open the project. Once again, if you're prompted to update your Grade O plugin, click the update button as many times as you need to. This application comes with the minimum and target (mumbles) versions both set to Android O.
I'm going to show you something really interesting in the manifest. The manifest for this application has two launcher activities. The first is the main activity and that's pretty normal. But then there's a second launcher activity called autofill settings and it navigates to a settings activity. The purpose of this settings activity is to let you manage a service and the service is declared at the bottom of the manifest, it's named my autofill service. Now the purpose of the autofill service is to provide data, so that when the user is in a data entry form, they can autofill the data entry form controls: the edit text views that is.
I'll demonstrate the application by running it on a virtual device, running on the Android emulator. The main activity looks like this: there's a button labeled sign in using standard views and I'll go back from there and one labeled sign in using virtual views. That one doesn't work without some modifications, so I'm going to stick with the standard views. In the standard views, when the user touches to give focus to the edit text control, you don't see any data provided and that's because, in order to use the autofill framework, you have to assign it in the settings.
So I'll drag down a couple of times and click the gear icon to open the settings, then I'll click the search tool and I'll type autofill and I'll go to the autofill app and from there I'll click on autofill app here. This screen is asking me to assign an application that will provide the data. I'll select autofill framework and then confirm, and then I'll reopen the autofill framework application, and now I see data automatically pop up that I can use to pre-fill the form.
I'll select user zero and click login and I'm told I've successfully signed on. Now, I'll back out of that entire application and then, from the app screen, I'll choose autofill settings and I'll increase the number of available data sets from two to five, I'll save, and then I'll once again open the autofill framework and open the standard view screen and now I see five items available. So here are some tips about navigating the code.
First of all, in the application under the java section, there's a section for the front end app and a section for the service. The autofill data class is providing the data. You'll find references here to user and then a numeric value and this is where the values are being created and there's also code in the main activity class that setting up the basic user interface. Th autofill helper and autofill field classes are doing a lot of the work as well. Now, I don't have time to code review this in depth, so I'll just let you know that this functionality is provided in a much more complex way than is really necessary in a smaller application, but this sample app can help you understand how you can use this new feature to make it easier for your users to navigate your data entry forms.
- Installing Android Studio 2.4 Preview
- Targeting Android O in a new project
- Setting up Android O testing devices
- Exploring the new features for users
- Using display notifications in channels
- Using Autofill EditText components
- Displaying video as picture-in-picture
- Exploring other new features for developers