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

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

问题描述

我有一个显示用户名 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天全站免登陆