How to generate a key using KeyGenerator for FingerPrint API in Android

I am trying to implement the FingerPrint API for my application. For this purpose, I follow the Google Fingerprint Dialog Box .

It works fine if compileSdkVersion=23 and minSdkVersion=23 , but my compileSdkVersion application is 21 and minSdkVersion is 14. For this purpose I use FingerprintManagerCompat instead of FingerprintManager , which works fine but the key generation problem is.

 android.security.keystore.KeyGenParameterSpec; android.security.keystore.KeyPermanentlyInvalidatedException; android.security.keystore.KeyProperties; 

Keystore package and its classes are not available for key generation, all supported key generation algorithms available in versions 18+ of the API can help me create a key to support lower versions?

+6
source share
1 answer

Looking at the FingerprintManagerCompat javadoc:

A class that coordinates access to fingerprint equipment.

On platforms up to M, this class behaves in a way that fingerprint equipment would not be available.

Looking at the source code:

 final int version = Build.VERSION.SDK_INT; if (version >= 23) { // a working implementation IMPL = new Api23FingerprintManagerCompatImpl(); } else { // an empty stub IMPL = new LegacyFingerprintManagerCompatImpl(); } 

If your device is below the VERSION 23 API, LegacyFingerprintManagerCompatImpl is used and this is only STUB. For instance:

 @Override public boolean hasEnrolledFingerprints(Context context) { return false; } @Override public boolean isHardwareDetected(Context context) { return false; } 

You cannot use such a function on an earlier device. These APIs (some of android.security.keystore) are only available on Android M

+2
source

All Articles