Share
Embed
Transcript
16 slides
-
Configure Autofill Service in your app Settings -> System/General Management
-> Language and Input -> Autofill Service android.permission.BIND_AUTOFILL_SERVICE -
Autofill Hints <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:autofillHints="password" /> val password =
findViewById<EditText>(R.id.password) password.setAutofillHints(View.AUTOFILL_HINT_PASSWORD) https://developer.android.com/reference/android/view/View?authuser=1#setAutofillHints(java.lang.String...) -
Field Importance <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:importantForAutofill="no" /> val captcha =
findViewById<TextView>(R.id.captcha) captcha.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO) Auto noExcludeDescendants Yes yesExcludeDescendants No -
Enable same Autofill across Web & App • Create a
Digital Asset Link JSON file • "relation": ["delegate_permission/common.ge t_login_creds"] • Host it at your web domain • Declare this association to your Android Manifest file https://developers.google.com/identity/smartlock-passwords/android/associate-apps-and-sites?authuser=1 -
Autofill Manager isEnabled(), cancel() fun eventHandler(view: View) { val afm
= requireContext().getSystemService(AutofillManager::class.java) afm?.requestAutofill(view) } AutofillManager.commit() -
Autofill process under the hood • AutofillManager#notifyViewEntered(android.view.View) • ViewStructure containing
all the screen views • onConnected() • onFillRequest(android.service.autofill.FillRequest, android.os.CancellationSignal, android.service.autofill.FillCallback) • FillCallback#onSuccess(FillResponse) • onDisconnected() -
Building your own autofill service <service android:name=".MyAutofillService" android:label="My Autofill Service"
android:permission="android.permission.BIND_AUTOFILL_SERVICE"> <intent-filter> <action android:name="android.service.autofill.AutofillService" /> </intent-filter> <meta-data android:name="android.autofill" android:resource="@xml/service_configuration" /> </service> -
SaveInfo Object SAVE_DATA val fillResponse: FillResponse = FillResponse.Builder() .addDataset( Dataset.Builder()
.setValue(parsedStructure.usernameId, null, notUsed) .setValue(parsedStructure.passwordId, null, notUsed) .build() ) .setSaveInfo( SaveInfo.Builder( SaveInfo.SAVE_DATA_TYPE_USERNAME or SaveInfo.SAVE_DATA_TYPE_PASSWORD, arrayOf(parsedStructure.usernameId, parsedStructure.passwordId) ).build() ) .build() ... -
Partitioned Datasets Credentials Address Payment Username Street Credit card number
password City Expiry Email address State CVV Zip Code -
Testing your app with Autofill - Summary • Get an
Autofill service • Enable the service in System Settings Settings > System > Language & input > Input assistance > Autofill service • Help the service with android:autofillHints & other attributes • Save data in the service • Trigger autofill in app https://github.com/googlesamples/android-AutofillFramework