Created
October 5, 2020 21:36
-
-
Save isaidamier/288509176d01714e08fc10471ed85d84 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