Created
October 18, 2020 09:17
-
-
Save NoobSolver/9f9e1483d0b0fb85c9b89fe5db8b1a53 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
binding.useBiometrics.setOnClickListener { | |
showBiometricPromptForEncryption() | |
} | |
.... | |
private fun showBiometricPromptForEncryption() { | |
val canAuthenticate = BiometricManager.from(applicationContext).canAuthenticate() | |
if (canAuthenticate == BiometricManager.BIOMETRIC_SUCCESS) { | |
val secretKeyName = SECRET_KEY_NAME | |
cryptographyManager = CryptographyManager() | |
val cipher = cryptographyManager.getInitializedCipherForEncryption(secretKeyName) | |
val biometricPrompt = | |
BiometricPromptUtils.createBiometricPrompt(this, ::encryptAndStoreServerToken) | |
val promptInfo = BiometricPromptUtils.createPromptInfo(this) | |
biometricPrompt.authenticate(promptInfo, BiometricPrompt.CryptoObject(cipher)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment