I am using BiometricManager (Introduced in Api 29) in a project with a minSdkVersion of 26.
To my surprise, the project is compiling and running, I would have expected this to throw an error at buildtime. Am I missing something? Will this cause issues on release?
Gradle:
defaultConfig {
minSdkVersion 26
targetSdkVersion 31
versionCode 1
versionName "1.0"
Class:
import androidx.biometric.BiometricManager;
import androidx.biometric.BiometricPrompt;
public BiometricPromptClass(Activity activity) {
this.context = activity.getBaseContext();
this.activity = activity;
}
public int getDeviceBiometricStatus(){
return getBiometricManager().canAuthenticate(BiometricManager.Authenticators.BIOMETRIC_WEAK);
}
public boolean CheckIfCanAuthenticate() {
if (getDeviceBiometricStatus() == BiometricManager.BIOMETRIC_SUCCESS) {
return true;
} else {
failureCode = getDeviceBiometricStatus();
return false;
}
}
CodePudding user response:
I am using BiometricManager
No, you are not... at least, not the one that you linked to. You linked to android.hardware.biometrics.BiometricsManager. Your code uses androidx.biometrics.BiometricsManager. Those are not the same class. The Jetpack (androidx) edition will have code that tries to support older devices gracefully.
