Skip to content

Instantly share code, notes, and snippets.

@navczydev
Last active April 15, 2022 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save navczydev/a5ec7064373a036f6e2bc13941caef19 to your computer and use it in GitHub Desktop.
Save navczydev/a5ec7064373a036f6e2bc13941caef19 to your computer and use it in GitHub Desktop.
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