I\'m asked to show certain UI elements depending on the presence of biometric hardware. For Android 23-27 I use FingerprintManager#isHardwareDetected()
and
The method - checks that the user has biometric authentication permission enabled for the app before using the package manager to verify that fingerprint authentication is available on the device. And even it will check if the user is enrolled or not.
implementation 'androidx.biometric:biometric:1.0.0-alpha03'
private Boolean checkBiometricSupport() {
KeyguardManager keyguardManager =
(KeyguardManager) getSystemService(KEYGUARD_SERVICE);
PackageManager packageManager = this.getPackageManager();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
notifyUser("This Android version does not support fingerprint authentication.");
return false;
}
if(!packageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
{
notifyUser("Fingerprint Sensor not supported");
return false;
}
if (!keyguardManager.isKeyguardSecure()) {
notifyUser("Lock screen security not enabled in Settings");
return false;
}
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.USE_BIOMETRIC) !=
PackageManager.PERMISSION_GRANTED) {
notifyUser("Fingerprint authentication permission not enabled");
return false;
}
return true;
}