Face authentication to unlock my app programmatically

Kanagalingam picture Kanagalingam · Dec 12, 2018 · Viewed 8.4k times · Source

I am developing an android app which uses fingerprint/face recognition for unlocking the app.

I have successfully integrated fingerprint authentication using BiometricPrompt. But didn't know where to start for Face authentication. Any headsup will be really helpful.

Also, Since BiometricPrompt comes with face, fingerprint, and iris, I don't want to use either MLKIT or any third party libraries.

Below is the piece of code I used for Fingerprint authentication.

new BiometricPrompt
    .Builder(context)
    .setTitle(title)
    .setSubtitle(subtitle)
    .setDescription(description)
    .setNegativeButton(negativeButtonText, context.getMainExecutor(),
                        new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            biometricCallback.onAuthenticationCancelled();
        }
    })
    .build()
    .authenticate(new CancellationSignal(), context.getMainExecutor(),
            new BiometricCallbackV28(biometricCallback));

Answer

saranhya narakedamilli picture saranhya narakedamilli · Dec 6, 2019

Android 10: Will allow both finger print and Face ID as currently in Samsung s10.

Android 9: Will allow only Fingerprint authentication (irrespective of face Id unlock exist or not )

reference link https://source.android.com/security/biometric/#source

Edit1: However the Samsung is not following google's ritual. Samsung will still have different behaviours .

1.Samsung - Android 9 - you can choose preferred biometrics and this applicable for the apps well.

But there is a bug. If you disable the finger print authentication for device level unlock you will get prompted for the fingerprint authentication in the app level.

  1. Samsung - Android 10 - you can keep all the authentications active at same time. In biometric prompt you can choose authentication.

Short summary :

enter image description here