保存为自动填充对话框未显示

2024-04-21

我有一个显示用户名 UI 的活动,输入该活动并点击继续按钮后会显示输入密码 UI。输入密码并点击登录按钮后,完成当前活动并启动新活动。在我的设备上,我选择了 Google 自动填充服务,因此在第一个活动完成后,我想要“保存以供自动填充?”对话框显示,但事实并非如此。我通过在我的活动中添加 autofillHints 和其他任何内容来准备我的应用程序。我应该添加任何内容才能弹出对话框吗?


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

1- 确保您已将以下权限添加到清单中:

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

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

3-要保存用户名和密码,您应该为用户名 editText 和密码 editText 添加:

android:importantForAutofill="yes"

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

 android:autofillHints="username"

对于密码 editText 您应该添加:

 android:autofillHints="password"

笔记: 你不应该使用textNoSuggestions对于密码的文本输入类型:

 android:inputType="textPassword|textNoSuggestions"

相反,您应该使用:

 android:inputType="textPassword"

4-您应该排除不需要的editText(验证码),以免被保存,因此您应该添加到验证码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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

保存为自动填充对话框未显示 的相关文章

  • 如何在android网络库(ION)中使用自签名SSL?

    使用此网络库 https github com koush ion https github com koush ion 由于当前状态是开发 我想使用自签名 SSL 证书 图书馆论坛有一些讨论 https github com koush
  • 使用 dpi 与 dp 缩放图像之间的差异

    我拥有所有由九个补丁位图组成的 dpi 可绘制目录 xxhdpi 和 xxxhdpi 是否必要 可绘制目录中的可绘制资源文件可检索所有缩放的位图 并且我使用可绘制资源文件 现在 我的问题是我还根据大小 小 正常等 创建了 缩放 布局目录 其
  • 使用一个 apk 安装两个应用程序

    我有 2 个应用程序 1 内容提供者 2 使用此 ContentProvider 的应用程序 我需要使用单个 apk 文件安装这 2 个应用程序 我想在 Eclipse 中同时推送这两个应用程序 如果我将另一个项目添加到一个应用程序的构建路
  • 使用 HttpClient 时,为什么服务器响应中省略了 Content-Length 标头?

    我正在使用这个问题的源代码如何异步执行httprequest并显示下载响应的进度 https stackoverflow com questions 9594318 how to asynchronous perform a httpreq
  • 如何在活动中的必填字段中显示 * 符号

    我需要在活动中的必填字段中显示 符号 你能建议我怎样才能做到这一点吗 任何帮助 将不胜感激 我想说 作为必填字段的标记不遵循本机 Android 主题 的组合setHint and setError对于 Android 应用程序来说看起来更
  • 更改卡片高度即更改 Jetpack 中与 Material 3 组合的卡片颜色

    我正在使用 Card 可组合项 我希望它的颜色为白色 但是当我向它添加一些高度时 它的颜色会更改为更像主要容器颜色 我看过文档 其中有一种称为高程覆盖的东西 但找不到说明如何使用它的示例 这是我的代码 Card modifier Modif
  • 当不支持 Google Play 应用内结算 V.3 时

    在 Google Play 的应用内结算 V 3 中 有一个选项可以检查用户设备是否支持它 使用是否支持计费 http developer android com google play billing versions html meth
  • 在 Android Lollipop 中从 Uri 中裁剪照片后总是返回 Null?

    我尝试在拍照或挑选照片后从 Uri 中裁剪图像 我的代码是这样的 public static void cropImage Uri uri Activity activity int action code Intent intent ne
  • Android Fragment onCreateView 与手势

    我正在尝试在片段中使用手势 我在 FragmentActivity 中有以下内容来处理我的详细信息片段 我试图发生的情况是 当在视图上检测到滑动时 将该视图内的数据替换为上一个或下一个条目 如果有更好的方法来处理这个问题 我完全同意 然而
  • Emma 不生成coverage.ec

    我设置了艾玛 它曾经对我有用 然后我们更改了源代码 现在它没有生成coverage ec根本不 它确实生成coverage em 测试临近结束时 出现错误消息 exec INSTRUMENTATION CODE 0 echo Downloa
  • 来自相机的 MediaCodec 视频流方向和颜色错误

    我正在尝试流式传输视频捕获直接从相机适用于 Android 设备 到目前为止 我已经能够从 Android 相机捕获每一帧预览帧 byte data Camera camera 函数 对数据进行编码 然后成功解码数据并显示到表面 我用的是安
  • 适用于 Android 的 Google 云端硬盘\文档 API

    我在几个小时内将 Dropbox 与我的应用程序集成 因为 SDK 描述清晰并且有很好的使用示例 Google Drive 似乎只有一个 一刀切 的 Gdata SDK 它非常重 有很多依赖项 它使我的应用程序的大小增加了三倍 而且不是很直
  • 屏幕开/关检测

    在这里 我试图确定屏幕是否打开 但按下电源锁定 解锁按钮时它似乎不起作用 应用程序运行没有错误 但 if else 中的代码似乎没有效果 Edited现在代码可以工作了 谢谢Olgun 但媒体播放器播放不会停止 并且每次在屏幕上 离屏时都会
  • SDK >=26 仍需要 mipmap/ic_launcher.png?

    在 Android 中 有两种指定启动器图标 可以说是应用程序图标 的方法 老 方式 在 mipmap 文件夹中指定不同的 png 文件 通常命名为 ic launcher png 但可以通过以下方式设置名称android icon mip
  • Glass 语音命令给定列表中最接近的匹配项

    使用 Glass 您可以通过 确定 Glass 菜单启动应用程序 它似乎会选择最接近的匹配项 除非命令相距数英里 并且您可以明显看到命令列表 无论如何 是否可以从应用程序内或从语音提示 在初始应用程序触发后 给出类似的列表并返回最接近的匹配
  • 我在 PopupMenu 中使用 ShareActionProvider,但显示两个 PopupMenu?

    我在 PopupMenu 中使用 ShareActionProvider 但是当我单击共享菜单项时 它会在屏幕上显示两个 PopupMenus 一个被另一个覆盖 一个显示应用程序图标和名称 另一个仅显示应用程序名称 除了这个问题之外 它工作
  • 在android中创建SQLite数据库

    我想在我的应用程序中创建一个 SQLite 数据库 其中包含三个表 我将向表中添加数据并稍后使用它们 但我喜欢保留数据库 就好像第一次安装应用程序时它会检查数据库是否存在 如果存在则更新它 否则如果不存在则创建一个新数据库 此外 我正在制作
  • 如何在Android中创建一个简洁的两栏输入表单?

    我想创建一个整洁的两列输入表单 如下所示 到目前为止我的 xml 布局代码
  • Flash 对象未显示在phonegap android 中

    我已经在 android 手机间隙创建了一个应用程序 我有一个屏幕 我想显示一个静态 flash obj 所以我在屏幕 HTML 页面中放入了以下代码
  • 如何正确编写AttributeSet的XML?

    我想创建一个面板适用于 Android 平台的其他小部件 http code google com p android misc widgets 在运行时 XmlPullParser parser getResources getXml R

随机推荐