As we have our App on Android O, there's a new feature introduced there, where it auto-suggest Home and Work location as per image below.
What is this called? Is there a way to disable it from our Edit Text showing it?
As we have our App on Android O, there's a new feature introduced there, where it auto-suggest Home and Work location as per image below.
What is this called? Is there a way to disable it from our Edit Text showing it?
Apparently in Android-Oreo, there's this new feature call AUTOFILL
https://developer.android.com/guide/topics/text/autofill.html, where By default, the view uses the IMPORTANT_FOR_AUTOFILL_AUTO mode, which lets Android use its heuristics to determine if the view is important for autofill
Hence for field that is not intended to have that filled, just add the below to your view.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
setImportantForAutofill(IMPORTANT_FOR_AUTOFILL_NO);
}
Update: Found another approach to disable AUTOFILL
Use android:importantForAutofill="no" in the XML
https://developer.android.com/guide/topics/text/testautofill.html#trigger_autofill_in_your_app
Accepted answer is not a solution, it doesn't work for all cases, to Disable the Autofill completely on a particular View you should extend it and override getAutofillType() method:
class TextInputEditTextNoAutofill : TextInputEditText {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
@RequiresApi(Build.VERSION_CODES.O)
override fun getAutofillType(): Int {
return View.AUTOFILL_TYPE_NONE
}
}
This is Kotlin version, but you can get the point. Showcase repo: https://github.com/BukT0p/AutofillBug