Reputation: 322
I'm setting up a biometric login using kotlin. I have it working but I would like to switch out which icon is displayed based on the available hardware, ie. show a retinal scanner icon for retinal scanning, fingerprint for fingerprint scanning etc. So far digging through the docs I haven't been able to find a way to determine this and the google machine hasn't been very useful.
something along the lines of
when (biometricManager.biometricType) {
face -> {}
fingerprint -> {}
retinaScanner -> {}
}
would be awesome. Does this exist?
Upvotes: 2
Views: 442
Reputation: 322
I figured it out, you use the package manager.
enum class BiometricType {
Iris, Fingerprint, Face, None
}
fun biometricType(context: Context): BiometricType {
return when {
context.applicationContext.packageManager.hasSystemFeature(PackageManager.FEATURE_FACE) -> BiometricType.Face
context.applicationContext.packageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT) -> BiometricType.Fingerprint
context.applicationContext.packageManager.hasSystemFeature(PackageManager.FEATURE_IRIS) -> BiometricType.Iris
else -> BiometricType.None
}
}
Hopefully this helps someone else out in the future
Upvotes: 2