Constant USE_FINGERPRINT
was deprecated in API level 28 and we should use more generic USE_BIOMETRIC
which has been added in same API level.
I swap these constants in my Manifest and I'm getting error when calling FingerprintManagerCompat.from(context).isHardwareDetected()
.
Error is:
Missing required permission - USE_FINGERPRINT
This happens because of @RequiresPermission("android.permission.USE_FINGERPRINT")
annotation in FingerprintManagerCompat
in 28.0.0-rc3 support v4 lib.
Is this something I can ignore and continue using new permission?
I've faced the same problem, imho the short answer is to ignore the deprecation, as long as you only want to support fingerprint authentication in your app.
As stated in the google dev blog, since API 28 google comes up with the new biometrics API, which simplifies the whole process of biometrics authentication. They provide a simple builder for the auth-dialog. Additionally, they support face and iris detection, too - imho it is just a matter of time if you want to support it and probably might be worth upgrading it.
The only disadvantage I've discovered so far is that if you want to check if e.g. fingerprint hardware is available, you'll have to start the authentication process to check this out and wait for the error callback. The deprecated fingerprint API instead provides methods like
isHardwareDetected()
orhasEnrolledFingerprints()
for this purpose. In this case, you would probably have to re-design your application, if you rely on this information. The reason for the deprecation of those methods is probably, that it only supports fingerprints, therefore it is not a bad idea to upgrade it.Google has also provided the compat
'androidx.biometric:biometric:1.0.0-alpha02'
version for the devices below API 28, it seems that by importing this dependency, you could simply switch toUSE_BIOMETRIC
permission without modifying anything else in your app - you won't be bothered by the warning anymore. Since it is only in alpha stage, I would use it with care. Therefore, as long as you don't use anything from the biometrics API, you could also simply ignore the problem and face it again when you want to support additional biometric authentication methods.EDIT: Now, the beta version of compat library is released,
'androidx.biometric:biometric:1.0.0-beta01'
. For more info on this, check here.Now, the stable version of compat library is released on December 18, 2019, 'androidx.biometric:biometric:1.0.1'. For more info on this Click here.
biometrics API provides BiometricConstants for error handling