如何在 Jetpack Compose 中集成自动填充
How to integrate autofill in Jetpack Compose
我想在完全使用 Jetpack Compose 编写的应用程序(电子邮件和密码)中提供一些自动填充功能。我遇到了 this blog post and this demo code 我都试过了。不幸的是,我在与文本字段交互时无法获得任何弹出窗口。
修改我的代码后,我最终使用了提供的演示。一个最小的示例如下所示(ExplicitAutofillTypesDemo
可组合项取自上面提到的演示代码,没有任何修改):
class MainActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
ExplicitAutofillTypesDemo()
}
}
}
我错过了什么?我需要在其他地方启用它吗?官方compose autofill documentation 帮助不大。我只想在触摸上面博客 post 中的文本字段时获得自动填充弹出窗口。
在我的例子中,弹出窗口没有显示是因为自动填充似乎不适用于 Google 以外的任何其他提供商。调试日志显示以下消息:
D/Autofill Status: Autofill popup isn't shown because autofill is not available.
Did you set up autofill?
1. Go to Settings > System > Languages&input > Advanced > Autofill Service
2. Pick a service
Did you add an account?
1. Go to Settings > System > Languages&input > Advanced
2. Click on the settings icon next to the Autofill Service
3. Add your account
我尝试使用 Microsoft Authenticator 作为示例,但它不起作用。当我切换到 Google 时,一切正常。
我想在完全使用 Jetpack Compose 编写的应用程序(电子邮件和密码)中提供一些自动填充功能。我遇到了 this blog post and this demo code 我都试过了。不幸的是,我在与文本字段交互时无法获得任何弹出窗口。
修改我的代码后,我最终使用了提供的演示。一个最小的示例如下所示(ExplicitAutofillTypesDemo
可组合项取自上面提到的演示代码,没有任何修改):
class MainActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
ExplicitAutofillTypesDemo()
}
}
}
我错过了什么?我需要在其他地方启用它吗?官方compose autofill documentation 帮助不大。我只想在触摸上面博客 post 中的文本字段时获得自动填充弹出窗口。
在我的例子中,弹出窗口没有显示是因为自动填充似乎不适用于 Google 以外的任何其他提供商。调试日志显示以下消息:
D/Autofill Status: Autofill popup isn't shown because autofill is not available.
Did you set up autofill?
1. Go to Settings > System > Languages&input > Advanced > Autofill Service
2. Pick a service
Did you add an account?
1. Go to Settings > System > Languages&input > Advanced
2. Click on the settings icon next to the Autofill Service
3. Add your account
我尝试使用 Microsoft Authenticator 作为示例,但它不起作用。当我切换到 Google 时,一切正常。