Android Question [SOLVED] BiometricManager - Biometric Authentication - Problem with NONE_ENROLLED

scsjc

Well-Known Member
Licensed User
Longtime User
I have a problem when it gives NONE_ENROLLED, I attach an example, when starting the application it checks


1º if Biometric.CanAuthenticate = SUCCESS then executes Biometric.Show ... check if is correct and LOAD APPLICATION
2º If Biometric.CanAuthenticate <> SUCCESS then it understands that the android has no registered fingerprints or hardware available and CONTINUE LOAD APPLICATION.
3º If you try to register an incorrect fingerprint X times, the system CLOSE THE APPLICATION PERFECTLY
4º But if the application loads during the first 30 seconds, Biometric.CanAuthenticate = NONE_ENROLLED and CONTINUE LOAD APPLICATION <<<<< THATS IS A PROBLEM --> This problem is because after trying to identify with FINGERPRINT, it goes on to identify with FACIAL UNLOCK and results in NONE_ENROLLED


B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("1")

    Biometric.Initialize(Me, "Authenticate")
    Dim res As String = Biometric.CanAuthenticate
    Label1.text = $"CanAuthenticate: ${res}"$

    If res = "SUCCESS" Then
        Biometric.Show("Please authenticate")
        Wait For Authenticate_Complete (Success As Boolean, ErrorMessage As String)
        Label1.text = Label1.text & $"
Authenticate: ${Success}
ErrorMessage: ${ErrorMessage}"$

        If Success Then
            'EXECUTE APP
            Msgbox2Async("run program", "", "OK", "", "", Null, False)
            Wait For Msgbox_Result (Result As Int)
            ExitApplication
        Else
            'CLOSE APP
            Msgbox2Async("ACCESS ERROR - CLOSE PROGRAM", "", "OK", "", "", Null, False)
            Wait For Msgbox_Result (Result As Int)
            ExitApplication
        End If
    Else
        'EXECUTE APP
        Msgbox2Async("run program", "", "OK", "", "", Null, False)
        Wait For Msgbox_Result (Result As Int)
        ExitApplication
    End If
End Sub


I think that problem is because the system launch FACIAL UNLOCK and is NONE_ENROLLED
I have been investigating and I think a solution is to force it to only be checked with FINGERPRINT, but not work, and I don't know how to apply this code.
B4X:
PromptInfoBuilder.RunMethod("setAllowedAuthenticators", Array(0)) ' 0 = All Authenticators
'PromptInfoBuilder.RunMethod("setAllowedAuthenticators", Array(1)) ' 1 = BiometricConstants.Authenticators.FINGERPRINT
'PromptInfoBuilder.RunMethod("setAllowedAuthenticators", Array("BiometricConstants.Authenticators.FINGERPRINT"))
'PromptInfoBuilder.RunMethod("setAllowedBiometricTypes", Array("BiometricConstants.BIOMETRIC_TYPE_FINGERPRINT"))



 

Attachments

  • BiometricExample.rar
    27.4 KB · Views: 143
Last edited:

scsjc

Well-Known Member
Licensed User
Longtime User
I just saw a quick and easy solution. WhatsAPP solves this by blocking the retry of loading the APP for 30 seconds from the last attempt. This way you avoid the problem.
I have updated the code with the same idea.



 

Attachments

  • BiometricExample.rar
    27.7 KB · Views: 146
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…