B4A Library BiometricManager - Biometric Authentication

i_view64_rpWKS7JTGJ.png


This class replaces FingerprintManager (https://www.b4x.com/android/forum/threads/fingerprint-authentication.72500/#content).
It works with all the device supported biometric authentication features.

Setup:
1. Open B4A Sdk Manager, search for biometric and install androidx.biometric:biometric.
2. Add to the activity:
B4X:
#AdditionalJar: androidx.biometric:biometric
#Extends: android.support.v7.app.AppCompatActivity
#AdditionalJar: androidx.arch.core:core-runtime
#AdditionalJar: androidx.appcompat:appcompat
3. Add to the manifest editor:
B4X:
AddPermission(android.permission.USE_BIOMETRIC)
AddPermission(android.permission.USE_FINGERPRINT)
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light">
    </style>
</resources>
)

Usage:
- Call CanAuthenticate. It will return "SUCCESS" if biometric authentication is supported and configured.
- Call Show to show the authentication dialog and wait for the Complete event.

See the attached example.
 

Attachments

  • Biometric.zip
    15.6 KB · Views: 257
Last edited:
1. Open B4A Sdk Manager, search for biometric and install androidx.biometric:biometric.
Hey
When I open B4A Sdk Manager and search for biometric I can not find androidx.biometric:biometric
Actually before it the Sdk Manager logger shows this:
B4X:
B4A Sdk Manager: 3.7
TempFolder = C:\Users\jafari\AppData\Roaming\ANYWHE~1\BASIC4~1\temp
DataFolder: C:\Users\jafari\AppData\Roaming\B4ASdkManager
SDK version: 4333796
Downloading: https://dl.google.com/dl/android/maven2/master-index.xml
error:
<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 404 (Not Found)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/logos/errorpage/error_logo-150x54.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/logos/errorpage/error_logo-150x54-2x.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/logos/errorpage/error_logo-150x54-2x.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/logos/errorpage/error_logo-150x54-2x.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>404.</b> <ins>That’s an error.</ins>
  <p>  <ins>That’s all we know.</ins>

what is the problem??
 
In many applications, they make users choose a password in case which touch id ( finger print or biometric authentication or ...) does not work.
1- Is it possible to add something like a button called "using your password" or set an event for "Cancel" button in authentication?
2- Is it possible to change name of "Cancel" button to something else like "Ok"?
 

jeronimovilar

Member
Licensed User
I´m trying the BiometricExample and shows in compile:

Convert byte code - optimized dex. Error
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
2 errors; aborting

Why?
 
Top