Last active
April 15, 2022 21:42
-
-
Save navczydev/a5ec7064373a036f6e2bc13941caef19 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
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