沙井建网站,12306网站开发费用,陕西省住房和城乡建设厅官网查询,天津地区个人网站备案android上的密码#xff08;其实不仅仅是密码#xff0c;可以是用户名也可以是邮箱#xff09;自动填充#xff0c;是需要考虑适配的。 官方文档#xff1a;https://developer.android.com/identity/autofill/autofill-optimize?hlzh-cn
什么是自动填充
手机厂商一般会…android上的密码其实不仅仅是密码可以是用户名也可以是邮箱自动填充是需要考虑适配的。 官方文档https://developer.android.com/identity/autofill/autofill-optimize?hlzh-cn
什么是自动填充
手机厂商一般会默认带一个。三星叫做passiqoo叫做密码保险箱小米叫做智能密码管理。 第三方的有google框架lastPassbitwarden等。 以上是自动填充服务。 然后就是需要我们app做的事情适配自动填充。
适配
说起来很简单。 只需要申明
android:autofillHintspassword
android:importantForAutofillyes 但是发现这个事情我们什么都不用做默认就能支持的手机有pixel小米等。但三星或者三方服务如lastpass可能存在一些问题。
其实官网上并没有说明有一种情况。坑就坑在必须要有email或username框 必须要有Email框存在才会被某些服务识别到密码框 因此 你必须要有另外一个用户名的输入框比如
android:autofillHintsemailAddress //username
android:importantForAutofillyes 才能生效。
而且某些界面比如你只存在一个输入密码的框那么它将不能被弹出密码选择器。 需要你隐藏一个邮箱输入框才能有效。 比如 //不能是goneincludeandroid:idid/hiddenEmaillayoutlayout/input_email_layoutandroid:visibilityinvisible android:layout_widthmatch_parentandroid:layout_height32dp/反之某些不想提示的 则
android:importantForAutofillno 代码调用
给出2个函数
/*** 在onCreate过程添加代码。可以让它支持autoFill* param autoFillHints 可以选如下* View.AUTOFILL_HINT_PASSWORD* View.AUTOFILL_HINT_EMAIL_ADDRESS* newPassword*/
fun EditText.makeAutoFill(autoFillHints:String) {setAutofillHints(autoFillHints)importantForAutofill View.IMPORTANT_FOR_AUTOFILL_YESimportantForAccessibility View.IMPORTANT_FOR_AUTOFILL_YES
}//在onCreate过程添加代码。可以让它不支持autoFill
fun EditText.makeNoAutoFill() {importantForAutofill View.IMPORTANT_FOR_AUTOFILL_NOimportantForAccessibility View.IMPORTANT_FOR_AUTOFILL_NO
}