我在android 10上使用vivo,我的代码非常简单,只需单击一个按钮即可进行身份验证
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_face_id)
biometricPrompt = BiometricPrompt(this, ContextCompat.getMainExecutor(this), object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
super.onAuthenticationError(errorCode, errString)
Log.d("Huang", " error $errString")
}
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
Log.d("Huang", " success")
}
override fun onAuthenticationFailed() {
super.onAuthenticationFailed()
Log.d("Huang", " fail")
}
})
promptInfo = BiometricPrompt.PromptInfo.Builder()
.setTitle("Biometric login for my app")
.setSubtitle("Log in using your biometric credential")
.setNegativeButtonText("Use account password")
.setDeviceCredentialAllowed(true)
.build()
val button = findViewById<Button>(R.id.login)
button.setOnClickListener {
biometricPrompt.authenticate(promptInfo)
}
}但它只显示手指身份验证

我已经在可以解锁屏幕的设置中打开了人脸认证

我怎么才能解决它呢?
发布于 2021-10-07 08:24:12
实际上,用于面部解锁的传感器(通常是摄像头)可能不能用于生物认证。因为生物认证需要诸如面部id或指纹之类的安全硬件。但是,您仍然可以尝试使用this documentation中描述的.setAllowedAuthenticators(BIOMETRIC_WEAK)来降低安全级别。
发布于 2021-10-10 08:46:49
并不是所有使用FaceID的设备都通过system/compat BiometricPrompt API提供面部身份验证。FaceUnlock在像素和三星设备上运行良好,但不适用于许多原始设备制造商解决方案(华为、Oppo、小米等)。
上述项目还允许通过非官方应用程序接口在小米、华为、摩托罗拉和其他设备上使用FaceID。对于您的情况,使用Vivo FaceID,库有相关的实现,但没有任何保证。
https://stackoverflow.com/questions/69476731
复制相似问题