Search code examples
androidandroid-biometric-promptandroid-biometric

How can I implement Biometric API in Android?


I want to use biometrics or password to lock/unlock images in my app. Biometric API can detect the biometrics but the "use password" option take the device's pin/password. I want the user to enter a password in-app and any password he wants.


Solution

  • I used the negative button. I set the text of negative button to "Use Password" and handled the negative button onclick in the onAuthenticationError callback method.

    if (errorCode == BiometricPrompt.ERROR_NEGATIVE_BUTTON) {
        //show the in app password dialog
    }