相关疑难解决方法(0)

16:跳过密码保存,因为可能会提示用户使用 Android 自动填充

我正在将谷歌智能锁集成到我的 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但它也不起作用。

android autofill google-smartlockpasswords android-8.0-oreo

6
推荐指数
1
解决办法
1206
查看次数

Android 一键登录:无法显示密码保存对话框

我正在尝试实现 Android 一键登录,但无法在此处显示此对话框:

密码保存对话框

我不断收到消息:com.google.android.gms.common.api.ApiException: 16: Skipping password saving since the user is likely prompted with Android Autofill.

我怎样才能解决这个问题?

代码:

private fun saveCredentials(email: String, password: String) {
    val signInPassword = SignInPassword(email, password)
    val savePasswordRequest =
        SavePasswordRequest.builder().setSignInPassword(signInPassword).build()

    // Show the password save dialog
    Identity.getCredentialSavingClient(this)
        .savePassword(savePasswordRequest)
        .addOnFailureListener {e ->
            Log.d(TAG, Log.getStackTraceString(e))
        }
        .addOnSuccessListener { result ->
            startIntentSenderForResult(
                result.pendingIntent.intentSender,
                REQUEST_CODE_SAVE_CREDENTIALS,
                null,   // fillInIntent
                0,      // flagsMask
                0,      // flagsValues
                0,      // extraFlags
                null)   // options
        }
}
Run Code Online (Sandbox Code Playgroud)

文档:https://developers.google.com/identity/one-tap/android/save-passwords

android google-signin google-one-tap

5
推荐指数
1
解决办法
973
查看次数