如何在 Jetpack Compose 中集成自动填充

LN-*_*-12 10 android android-autofill-manager android-jetpack-compose

我想在我的应用程序中提供一些自动填充功能(电子邮件和密码),该功能完全使用 Jetpack compose 编写。我偶然发现了这篇博文和我都尝试过的演示代码。不幸的是,与文本字段交互时我无法收到任何弹出窗口。

修改我的代码后,我最终使用了提供的演示。一个最小的示例如下所示(ExplicitAutofillTypesDemo可组合项取自上面提到的演示代码,没有任何修改):

class MainActivity: AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContent {
            ExplicitAutofillTypesDemo()
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我缺少什么?我需要在其他地方启用它吗?官方撰写自动填充文档不是很有帮助。我只想在触摸文本字段时获得自动填充弹出窗口,如上面的博客文章中所示。

LN-*_*-12 9

就我而言,由于自动填充似乎不适用于除 Google 之外的任何其他提供商,因此未显示弹出窗口。调试日志显示以下消息:

\n
D/Autofill\xc2\xa0Status: Autofill popup isn\'t shown because autofill is not available.\n    \n    Did you set up autofill?\n    1. Go to Settings > System > Languages&input > Advanced > Autofill Service\n    2. Pick a service\n    \n    Did you add an account?\n    1. Go to Settings > System > Languages&input > Advanced\n    2. Click on the settings icon next to the Autofill Service\n    3. Add your account\n
Run Code Online (Sandbox Code Playgroud)\n

我尝试了 Microsoft Authenticator 作为示例,但不起作用。当我切换到谷歌时,一切都按预期进行。

\n