You do this using the new android:autofillHints attribute to tell autofill what type of content you expect, and android:importantForAutofill to tell autofill which views you want (or do not want) to be filled. To the component to tell it is not important to fill and get rid of the error.
The autofill service attempts to determine the type of each view using heuristics. However, if your app relies on these heuristics, autofill behavior may unexpectedly change as you update your app. To ensure that the autofill service correctly identifies your app's form factors, you should provide autofill hints.
Perhaps you are using an EditText. autofillHints is used in API 26 and above for filling empty EditTexts and it's actually suggesting which type of content should be placed in there.
Just add :
android:autofillHints="username" // the type of content you want
To your EditText and warning will disappear.
You do this using the new
android:autofillHintsattribute to tellautofillwhat type of content you expect, andandroid:importantForAutofillto tellautofillwhich views you want (or do not want) to be filled.
Read: https://medium.com/@bherbst/getting-androids-autofill-to-work-for-you-21435debea1
And this: https://developer.android.com/guide/topics/text/autofill-services
Edit:
You can however set:
android:importantForAutofill="no"
To the component to tell it is not important to fill and get rid of the error.
autofillHints
minSdk>=26 .
Should use android:importantForAutofill=no if you don't want autofill hint
<EditText
android:importantForAutofill="no"/>
minSdk<26
Add android:importantForAutofill then tools:targetApi to make IDE don't this warning about API level
<EditText
android:importantForAutofill="no"
tools:targetApi="o"
/>
autofillHints
Autofill service enable by default even if we don't set autofillHints attribute. specify an autofillHints will help autofill service work better like our expection. see documents here
minSdk>=26
Just need to add android:autofillHints="{a contant value}" (eg: "android:autofillHints="password") (use constant from here)
minSdk<26, add tools:targetApi to make IDE don't this warning
<EditText
android:autofillHints="emailAddress"
tools:targetApi="o"/>
Note
autofillHints and importantForAutofill only used in API 26 and higher but we still can use it in API < 26 without crash (you can see in this answer) (it don't crash but ofcourse it don't have any effect with API < 26)
tool:... just use to make IDE don't warning, it will not effect anything when application running so tools:ignore="Autofill don't help you hide autofill hint
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With