0

I have tried to setup fingerprint, pattern/password/pin, faceUnlock for my app. But Biometric doesn't works it always showing fingerprint with use pattern dialog. Is Still Biometrics not support FaceUnlock? If Not supported Biometric dependency means which library I should use in my app which contains fingerprint, pattern/password/pin and faceUnlock.

class LoginActivity : AppCompatActivity(){

private lateinit var biometricPrompt: BiometricPrompt
private lateinit var executor: Executor
private lateinit var callBack: BiometricPrompt.AuthenticationCallback
lateinit var prompt: BiometricPrompt.PromptInfo
private var keyguardManager: KeyguardManager? = null

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    val binding = DataBindingUtil.setContentView<ActivityLoginBinding>(this, R.layout.activity_login)
    executor = ContextCompat.getMainExecutor(this)
    biometricPrompt = BiometricPrompt(this, executor, object: BiometricPrompt.AuthenticationCallback(){
        override fun onAuthenticationFailed() {
            super.onAuthenticationFailed()
            tvAuthStatus.text = "Authentication Failed"
        }

        override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
            super.onAuthenticationSucceeded(result)
            startActivity(Intent(this@LoginActivity, MainActivity::class.java))
            finish()
            tvAuthStatus.text = "Authentication Success"
        }

        override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
            super.onAuthenticationError(errorCode, errString)
            tvAuthStatus.text = "Error" + errString
        }
    })

    prompt = BiometricPrompt.PromptInfo.Builder()
        .setTitle("RoomDB FingerPrint Login")
        .setNegativeButtonText("Login using fingerprint or face")
        .setNegativeButtonText("Cancel")
        .build()

    btnAuth.setOnClickListener {
        biometricPrompt.authenticate(prompt)
    }
}

}

Riya
  • 41
  • 4

1 Answers1

0

Maybe, in your case, the reason is your test device is released with the face authentication feature before the same API for face authentication appears in the official Android SDK. It makes third-party applications in your test device cannot use face authentication. Check this library, it said about this thing in README.md "I have a device that can be unlocked using Fingerprint/Face/Iris and(or) I can use this biometric type in pre-installed apps. But it doesn't work on 3rd party apps. Can you help?" https://github.com/sergeykomlach/AdvancedBiometricPromptCompat#i-have-a-device-that-can-be-unlocked-using-fingerprintfaceiris-andor-i-can-use-this-biometric-type-in-pre-installed-apps-but-it-doesnt-work-on-3rd-party-apps-can--you-help Hope it can help.

Tuan
  • 11
  • 3