Disabling Android O auto-fill service for an application

后端 未结 10 1695
死守一世寂寞
死守一世寂寞 2020-11-27 05:13

Android O has the feature to support Auto-filling for fields. Is there any way I can disable it for a specific application. That is I want to force my application not to use

相关标签:
10条回答
  • 2020-11-27 05:51

    In your EditText attributes add android:importantForAutofill="no" This should be a temporary fix and will only apply to api 26+

    0 讨论(0)
  • 2020-11-27 05:54

    Had the same problem with API 28+ and disable Autofill. For me the only solution was to disable long click for my views.

                    <com.google.android.material.textfield.TextInputEditText
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:longClickable="false"
                        android:text="@={model.emailAdress}"/>
    
    0 讨论(0)
  • 2020-11-27 06:02

    Seems to be a bug that needs to be fixed : https://issuetracker.google.com/issues/67675432
    In the meanwhile a workaround for now is to disable the AutoFill feature for the whole project. You can add in the values-v26/styles.xml file the following style or you can edit your BaseEditTextStyle if you are using a specific style for your EditText views.

    <style name="App_EditTextStyle" parent="@android:style/Widget.EditText">
    <item name="android:importantForAutofill">noExcludeDescendants</item>
    </style>
    

    and in the values-v26/themes.xml file you can simply add to the default theme that you are using in your app the items editTextStyle and android:editTextStyle like following :

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    ...
    <item name="android:editTextStyle">@style/App_EditTextStyle</item>
    <item name="editTextStyle">@style/App_EditTextStyle</item>
    </style>
    

    this way you can apply this changes for all your EditTexts without needing to change your layout files or Activities (and later on you can easily remove it when the bug is fixed).

    0 讨论(0)
  • 2020-11-27 06:03

    Is it possible ?

    Not that I am aware of. Certainly, nothing is documented.

    Is there any better method than this ?

    Not that I am aware of.

    0 讨论(0)
提交回复
热议问题