0

I have added Biometric Prompt in my Android app. So on app start, I am able to show prompt and if success is able to redirect user on the Dashboard screen. In case user failed I want to show System password as a secondary option to authenticate. How to do that with Biometric Prompt?

mBiometricManager = new BiometricManager.BiometricBuilder(FingerprintActivity.this)
                .setTitle(getString(R.string.biometric_title))
                .setSubtitle(getString(R.string.biometric_subtitle))
                .setDescription(getString(R.string.biometric_description))        
                .setNegativeButtonText(getString(R.string.biometric_negative_button_text))
                .build();

 mBiometricManager.authenticate(FingerprintActivity.this);
Jasurbek
  • 2,946
  • 3
  • 20
  • 37
sagarchavan
  • 187
  • 3
  • 14

2 Answers2

1

on your biometric prompt add this

.setDeviceCredentialAllowed(true)

But check phone has a password/passcode setup with:

android.app.KeyguardManager.isDeviceSecure()
Haider Malik
  • 1,581
  • 1
  • 20
  • 23
0

You can handle by extending BiometricPrompt.AuthenticationCallback, there are two main methods for handling fail state. onAuthenticationError and onAuthenticationFailed

onAuthenticationFailed

When the fingerprint doesn’t match with any of the fingerprints registered on the device, then this callback will be triggered.

onAuthenticationError

When an unrecoverable error has been encountered and the authentication process has completed without success, then this callback will be triggered. The callback is provided with an error code to identify the cause of the error

You can use Device administration API for showing system password in the case of Biometic auth fail.

Sanjay Bhalani
  • 2,424
  • 18
  • 44
  • Can you please provide some link with example? Because I cannot find anything? And one more thing is that Device Administration API deprecated from Android P. – sagarchavan Jun 24 '19 at 08:31
  • pls try this one https://stackoverflow.com/questions/9724428/how-can-i-set-up-screen-lock-with-a-password-programmatically – Sanjay Bhalani Jun 24 '19 at 10:24
  • Tried this, but it asked me to set Password, whereas password is already set. Instead what I want is, if biometric authentication failed, will show user a password field so that he can enter system password and redirect to Dashboard. – sagarchavan Jun 26 '19 at 08:58