Disabling Android O auto-fill service for an application Disabling Android O auto-fill service for an application android android

Disabling Android O auto-fill service for an application


Currently there is no direct way to disable the autofill for an entire application, since the autofill feature is View specific.

You can still try this way and call BaseActivity everywhere.

public class BaseActivity extends AppCompatActivity {    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       disableAutofill();    }    @TargetApi(Build.VERSION_CODES.O)    private void disableAutofill() {         getWindow().getDecorView().setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS);    }}

You can also force request autofill this way.

public void forceAutofill() {    AutofillManager afm = context.getSystemService(AutofillManager.class);    if (afm != null) {        afm.requestAutofill();    }}

Note: At the moment autofill feature is only available in API 26 Android Oreo 8.0

Hope this helps!


I believe the accepted answer is incorrect:

So I have my own class which is extends the android.support.v7.widget.AppCompatEditText and all I did is overwrote the following method with the following value:

@Overridepublic int getAutofillType() {    return AUTOFILL_TYPE_NONE;}

no other solutions worked, not even android:importantForAutofill="no".

getAutofillType() comes from the View class, so it should work for every other class such as TextInputEditText too!


I ran into this too. It turns out the issue was caused by setting the hint text on the EditText nested inside the TextInputLayout.

I did some digging and found this nugget in the 26.0.0 Beta 2 release notes.Andorid Support Release Notes June 2017

TextInputLayout must set hints on onProvideAutofillStructure()

That led me to try setting the hint on the TextInputLayout instead of the nested EditText.

This resolved the crashing issue for me.Example:

            <android.support.design.widget.TextInputLayout                android:id="@+id/textInputLayout"                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:hint="Some Hint Text"                android.support.design:hintAnimationEnabled="true"                android.support.design:hintEnabled="true"                android.support.design:layout_marginTop="16dp">                <android.support.design.widget.TextInputEditText                    android:id="@+id/editText"                    android:layout_width="match_parent"                    android:layout_height="wrap_content"/>            </android.support.design.widget.TextInputLayout>