BiometricHelper- Fingerprint recognition, face recognition, custom pop-ups, super easy to use
Making the address Yards cloud address
Based on android native fingerprint recognition and facial recognition tools, you can customize pop-ups as required
Project presentations
Features and functions:
- Support system pop-ups
- SDK pop-ups are supported
- Supports custom pop-ups
Less than Android 6 Api less than 23 |
---|
Does not support |
Android 6 to 8 Api 23 to 27 | Support SDK pop-ups/custom pop-ups | Support system pop-ups | Support for facial recognition |
---|---|---|---|
Don’t open enableAndroidP | true | false | false |
Open enableAndroidP | true | false | false |
Android 9 Api 28 | Support SDK pop-ups/custom pop-ups | Support system pop-ups | Support for facial recognition |
---|---|---|---|
Don’t open enableAndroidP | true | false | false |
Open enableAndroidP | false | true | false |
The value must be greater than or equal to Android 10 | Support SDK pop-ups/custom pop-ups | Support system pop-ups | Support for facial recognition |
---|---|---|---|
Don’t open enableAndroidP | true | false | false |
Open enableAndroidP | false | true | true |
FAQ
- Why does facial recognition popup window not appear when accessing SDK?
- Many phones don’t have face unlock
- Face unlock is not enabled
- Face unlock is available and the recognition popup window may not appear when face unlock is enabled
- Currently, I know Samsung S21 is capable of facial recognition. If you have more models, you can leave a message if you turn up the popup window of facial recognition
- Why is there no fingerprint recognition when accessing SDK?
- The fingerprint unlock function is not supported or disabled
How to add
Gradle added:
1. In the Projectbuild.gradle
Add the warehouse address to
allprojects {
repositories{... maven { url"https://jitpack.io"}}}Copy the code
2. In Module directorybuild.gradle
Add a dependency to
dependencies {
implementation 'com.github.ITxiaoguang:BiometricHelper:xxx'
}
Copy the code
Usage:
Requires fingerprint permission
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
Copy the code
Main calling code
private fun showDialog(enableAndroidP: Boolean) {
BiometricPromptManager.Builder(this)
// Start android popover default true, set to false Facial recognition does not take effect
.enableAndroidP(enableAndroidP)
.setCallback(fingerprintCallback)
.title("Please verify fingerprints/faces entered.")
.cancelText("Cancel")
// enableAndroidP false Only for android 8 or later
.setImgRes(R.drawable.ic_fingerprint)
.failTitle("Failed to identify fingerprints.")
.failContent("Try it again.")
// Custom pop-ups (using factory mode, inheriting IBiometricDialog)
//.setCustomDialog(BiometricDialogCustomImpl())
.build()
}
private val fingerprintCallback: FingerprintCallback = object : FingerprintCallback {
@RequiresApi(api = Build.VERSION_CODES.M)
override fun onSucceeded23(result: FingerprintManagerCompat.AuthenticationResult?). {
Toast.makeText(this@MainActivity."success", Toast.LENGTH_SHORT).show()
}
@RequiresApi(api = Build.VERSION_CODES.P)
override fun onSucceeded28(result: androidx.biometric.BiometricPrompt.AuthenticationResult?). {
Toast.makeText(this@MainActivity."success", Toast.LENGTH_SHORT).show()
}
override fun onFailed(a) {
Toast.makeText(this@MainActivity."onFailed", Toast.LENGTH_SHORT).show()
}
override fun onError(errString: CharSequence?). {
Toast.makeText(this@MainActivity."onError " + errString, Toast.LENGTH_SHORT).show()
}
override fun onCancel(a) {
Toast.makeText(this@MainActivity."onCancel", Toast.LENGTH_SHORT).show()
}
}
/** * onPause lifecycle closes custom popovers */
override fun onPause(a) {
super.onPause()
if (null! = manager) { manager!! .onActivityPause() } }/** * onDestroy lifecycle close custom popovers */
override fun onDestroy(a) {
super.onDestroy()
if (null! = manager) { manager!! .onActivityDestroy() } }Copy the code