保存为自动填充对话框未显示 [英] Save for autofill dialog not showing up

查看:108
本文介绍了保存为自动填充对话框未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个活动,显示用户名UI,输入该用户名并点击继续"按钮后,将显示输入密码UI.输入密码并点击登录按钮,即可完成当前活动并启动新活动.在我的设备上,我选择了Google自动填充服务,因此在第一个活动完成后,我想要保存为自动填充?"对话框出现,但不是.我通过添加autofillHints和我的活动中的其他内容来准备我的应用程序.我应该添加任何内容以使对话框弹出吗?

I have an activity that shows username UI, after entering that and tapping on continue button shows the enter password UI. On entering password and tapping on login button finishes the current activity and launches a new activity. On my device I selected Google autofill service, so on finish of the 1st activity I want "save for autofill?" dialog to show up, but it isn't. I prepared my app by adding autofillHints and nothing else in my activity. Should I add anything for the dialog to pop up?

推荐答案

我遇到了与您的情况类似的问题,请找到解决方法:

I was having a similar issue to your case, kindly find the solution:

1-确保您添加了以下权限来进行显示:

1- Make sure that you added the following permission to manifest:

    <uses-permission
    android:name="android.permission.BIND_AUTOFILL_SERVICE"
    tools:ignore="ProtectedPermissions" />

2-假设在您的登录屏幕中,您有三个 EditText (用户名,密码和验证码),因此您必须为所有编辑文本添加 android:importantForAutofill 在屏幕上.如果您错过添加操作(例如,对于验证码,则无需保存它),那么不幸的是,自动填充对话框将不会显示.

2- Let's say in your login screen you have three EditText (username, password, and captcha), So you MUST add android:importantForAutofill for all the edit texts in the screen. If you missed adding it (for example for captcha cause no need to save it), Unfortunately, the autofill dialog will not show up.

3-要保存用户名和密码,应同时添加用户名editText和密码editText:

3- To save username and password you should add for both username editText and password editText:

android:importantForAutofill="yes"

对于用户名editText,您应该添加:

for username editText you should add :

 android:autofillHints="username"

对于密码editText,您应该添加:

for password editText you should add :

 android:autofillHints="password"

注意:您不应将 textNoSuggestions 用作密码的文本输入类型:

NOTE: You should NOT use textNoSuggestions for text input type for the password:

 android:inputType="textPassword|textNoSuggestions"

相反,您应该使用:

 android:inputType="textPassword"

4-您应排除不需要的editText(Captcha),以免保存,因此应将其添加到验证码editText:

4- you should exclude the unwanted editText (Captcha) so as not be saved, So you should add to the captcha editText:

 android:importantForAutofill="noExcludeDescendants"  

5-这是代码段:

com.google.android.material.textfield.TextInputLayout
            android:id="@+id/usernameTextInputLayout"
            style="@style/TextInputStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/margin_16"
            android:layout_marginEnd="@dimen/margin_16"
            android:layout_marginBottom="@dimen/margin_16"
            app:endIconDrawable="@drawable/ic_username"
            app:endIconMode="custom"
            app:endIconTint="?attr/theme_primary">

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/usernameEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:autofillHints="username"
                android:hint="@string/hint_username"
                android:imeOptions="actionNext"
                android:importantForAutofill="yes"
                android:inputType="text"
                android:maxLines="1"
                android:textAlignment="viewStart" />

        </com.google.android.material.textfield.TextInputLayout>

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/passwordTextInputLayout"
            style="@style/TextInputStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/margin_16"
            android:layout_marginEnd="@dimen/margin_16"
            android:layout_marginBottom="@dimen/margin_16"
            app:endIconDrawable="@drawable/ic_password"
            app:endIconMode="custom"
            app:endIconTint="?attr/theme_primary">

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/passwordEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:autofillHints="password"
                android:hint="@string/hint_password"
                android:importantForAutofill="yes"
                android:inputType="textPassword"
                android:textAlignment="viewStart" />

        </com.google.android.material.textfield.TextInputLayout>

 <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/captchaTextInputLayout"
                style="@style/TextInputStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="@dimen/margin_16"
                android:layout_marginEnd="@dimen/margin_16"
                android:layout_marginBottom="@dimen/margin_16"
                android:importantForAutofill="noExcludeDescendants"
                app:boxCornerRadiusTopEnd="0dp"
                app:boxCornerRadiusTopStart="0dp">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/captchaEditText"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/hint_captcha_input"
                    android:imeOptions="actionNext"
                    android:importantForAutofill="noExcludeDescendants"
                    android:inputType="numberDecimal"
                    android:maxLength="@integer/otp_input_length"
                    android:maxLines="1"
                    android:textAlignment="viewStart" />

            </com.google.android.material.textfield.TextInputLayout>

这篇关于保存为自动填充对话框未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆