-
-
Save vinodbaste/05c07cddb9d2a35a3817eeb6e6373724 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun initBiometricPrompt( | |
activity: AppCompatActivity, | |
listener: BiometricAuthListener | |
): BiometricPrompt { | |
// 1 | |
val executor = ContextCompat.getMainExecutor(activity) | |
// 2 | |
val callback = object : BiometricPrompt.AuthenticationCallback() { | |
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) { | |
super.onAuthenticationError(errorCode, errString) | |
listener.onBiometricAuthenticationError(errorCode, errString.toString()) | |
} | |
override fun onAuthenticationFailed() { | |
super.onAuthenticationFailed() | |
Log.w(this.javaClass.simpleName, "Authentication failed for an unknown reason") | |
} | |
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) { | |
super.onAuthenticationSucceeded(result) | |
listener.onBiometricAuthenticationSuccess(result) | |
} | |
} | |
// 3 | |
return BiometricPrompt(activity, executor, callback) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment