Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make BiometricPrompt non-cancelable?

I am using BiometricPrompt in my application. It works well and shows the dialog when call the authenticate() method. But this dialog gets closing when I click outside the dialog. How to prevent it? How to make BiometricPrompt's dialog non-cancelable? Here is no method like biometricPrompt.setCancelable(false).

like image 580
BArtWell Avatar asked Jun 06 '19 10:06

BArtWell


Video Answer


1 Answers

BiometricPrompt does not allow that. So you won't be able to make the system-provided biometric prompt non-cancelable. But you can detect whenever user cancels the dialog.

So an option would be, to show again the biometric prompt after user cancel it (which I think would be a bad user experience) or use alternate user authentication:

override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
        if (errorCode == BiometricConstants.ERROR_USER_CANCELED) {
            // User canceled the operation

            // you can either show the dialog again here

            // or use alternate authentication (e.g. a password) - recommended way
        }
    }
like image 191
mgcaguioa Avatar answered Oct 11 '22 06:10

mgcaguioa