0

I use vivo with android 10 and my code is very simple just one button and click it to authenticate

 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)
        }
    }

But it only show finger Authentication enter image description here I have already open face Authentication in setting which can unlock screen enter image description here How can i solve it

GHH
  • 1,713
  • 1
  • 8
  • 21
  • The simple answer is, you Phone does not comply to the Google Biometrics API and therefore Face Auth is not supported. – Javatar Oct 07 '21 at 08:43
  • @Javatar Okay:(. Do you know what devices support? I know Pixels support it, anything else? – GHH Oct 07 '21 at 09:02
  • No, there are way too many devices on the market and it changes all the time. – Javatar Oct 07 '21 at 10:39

2 Answers2

0

Actually, sensors(usually cameras) for face unlocking may not be used for biometric authentication. Because biometric authentication needs secure hardware such as face id or fingerprint. But still, you can try to reduce the security level with .setAllowedAuthenticators(BIOMETRIC_WEAK) as described in this documentation.

Mustafa Kuloğlu
  • 1,122
  • 1
  • 8
  • 16
  • Thank for your answer. I add`.setAllowedAuthenticators(BiometricManager.Authenticators.BIOMETRIC_STRONG)` but nothing change. – GHH Oct 07 '21 at 08:46
  • So, I think your phone may not support biometric authentication with the face. – Mustafa Kuloğlu Oct 07 '21 at 08:57
  • Okay:(. Do you know what devices support? I know `Pixels` support it, anything else? – GHH Oct 07 '21 at 09:01
  • I am not sure. I am a Pixel 4xl user and yes this phone is supporting face Id. But Samsung S10+ may also support face id, according to this post's comment. https://stackoverflow.com/a/63343041/6183507 – Mustafa Kuloğlu Oct 07 '21 at 09:12
  • By the way, I realized I typed wrong about BIOMETRIC_STRONG and I updated the post. Please try with BIOMETRIC_WEAK. – Mustafa Kuloğlu Oct 07 '21 at 09:14
  • I try `BIOMETRIC_WEAK` still the same result – GHH Oct 07 '21 at 09:48
0

Not all devices with FaceID provide face authentication via system/compat BiometricPrompt API. FaceUnlock works well on Pixel and Samsung devices, but doesn't work for many OEM solutions (Huawei, Oppo, Xiaomi etc).

Why this happens is described here: https://github.com/Salat-Cx65/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

The project above also allows use with FaceID on Xiaomi, Huawei, Moto and other devices via unofficial API. For your case, with Vivo FaceID, the library has related implementation, but without any guarantees.

ouflak
  • 2,458
  • 10
  • 44
  • 49