2

I have implemented finger-print Biometric auth in my project. I have set a fallback auth in case user wants to use pattern/pin/passcode by clicking on "Use Password" button. I have done this by using setDeviceCredentialAllowed(true) which works for the first time. But whenever I do this again, the pattern/pin/passcode screen never appears again. I get a following log in the logcat console:

BiometricPromptCompat: Failed to check device credential. Parent handler not found

Here is my code for reference. Thanks in advance.

executor = ContextCompat.getMainExecutor(this);
    biometricPrompt = new BiometricPrompt(MainActivity.this,
            executor, new BiometricPrompt.AuthenticationCallback() {
        @Override
        public void onAuthenticationError(int errorCode,
                                          @NonNull CharSequence errString) {
            super.onAuthenticationError(errorCode, errString);
            Toast.makeText(getApplicationContext(),
                    "Authentication error: " + errString, Toast.LENGTH_SHORT)
                    .show();
        }

        @Override
        public void onAuthenticationSucceeded(
                @NonNull BiometricPrompt.AuthenticationResult result) {
            super.onAuthenticationSucceeded(result);
            Toast.makeText(getApplicationContext(),
                    "Authentication succeeded!", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onAuthenticationFailed() {
            super.onAuthenticationFailed();
            Toast.makeText(getApplicationContext(), "Authentication failed",
                    Toast.LENGTH_SHORT)
                    .show();
        }
    });

    promptInfo = new BiometricPrompt.PromptInfo.Builder()
            .setTitle("Biometric login for my app")
            .setSubtitle("Log in using your biometric credential")
            .setDeviceCredentialAllowed(true)
            .setConfirmationRequired(true)
            .build();

    biometricPrompt.authenticate(promptInfo);
Amey Bhandarkar
  • 511
  • 2
  • 5
  • 14

1 Answers1

2

I faced this issue only in Xiaomi devices and I had to create a new PromptInfo every time instead of reusing the first one if I had to call biometric auth again to fix this error.

val promptInfo = BiometricPrompt.PromptInfo.Builder()
                .setTitle(getString(R.string.authenticate_card_creation))
                .setSubtitle(getString(R.string.authenticate_creation_description_virtual))
                .setDeviceCredentialAllowed(true)
                .setConfirmationRequired(false)
                .build()
hushed_voice
  • 3,161
  • 3
  • 34
  • 66