我正在将谷歌智能锁集成到我的 Android 应用程序中,但在某些设备中,当我尝试将凭据保存到谷歌时,我收到此错误。我正在使用以下代码来保存凭据 -
Credential credential = new Credential.Builder(email)
.setPassword(password)
.build();
saveCredentials(credential);
Run Code Online (Sandbox Code Playgroud)
在谷歌上搜索此解决方案后发现需要禁用应用程序中的自动填充功能来保存密码。
尝试 1 - 将以下代码放入特定活动中的 commit autofillmager 活动中并禁用自动填充。但它不起作用。
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
AutofillManager autofillManager = getSystemService(AutofillManager.class);
autofillManager.commit();
getWindow()
.getDecorView()
.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS);
}
Run Code Online (Sandbox Code Playgroud)
尝试 2 - 将以下内容放入属性中EditText
android:longClickable="false"
Run Code Online (Sandbox Code Playgroud)
longClickable 应该停止自动填充,但它不起作用。
android:importantForAutofill="no"
Run Code Online (Sandbox Code Playgroud)
也尝试使用,importantForAutoFill但它也不起作用。