Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
val biometricManager = BiometricManager.from(this)
var result = listOf<String?>()
if (biometricManager.canAuthenticate(BIOMETRIC_STRONG) == BiometricManager.BIOMETRIC_SUCCESS) {
when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val bioMetricHardwareManager = (applicationContext.getSystemService(Context.BIOMETRIC_SERVICE) as? android.hardware.biometrics.BiometricManager)
bioMetricHardwareManager?.getStrings(Authenticators.BIOMETRIC_WEAK or Authenticators.BIOMETRIC_STRONG)
?.run {
result = listOf(
buttonLabel?.toString(),
promptMessage?.toString(),
settingName?.toString()
)
}
}
else -> {
// NOT_AVAILABLE_FOR <API 12
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment