How to generate key using KeyGenerator for FingerPrint API in Android
Asked Answered
N

1

7

I am trying to implement the FingerPrint API for my application. I am following the Google's Fingerprint Dialog sample for this purpose.

It works fine if compileSdkVersion=23 and minSdkVersion=23 but my application's compileSdkVersion is 21 and minSdkVersion is 14. For this purpose, I am using FingerprintManagerCompat instead of FingerprintManager which works fine but the issue is with the Key generation.

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

Keystore package and its classes are not available to generate the key, all the supported algorithms for the key generation available in 18+ API versions, anybody can guide me how to generate the key to support lower versions, please?

Naashom answered 11/2, 2016 at 14:43 Comment(1)
The devices lower than these does not have finger print sensor, so i dnt think so it would be necessary to give backward support.Caniff
A
2

Looking at FingerprintManagerCompat javadoc:

A class that coordinates access to the fingerprint hardware.

On platforms before M, this class behaves as there would be no fingerprint hardware 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 API VERSION 23, the LegacyFingerprintManagerCompatImpl is used, and this is only a STUB. For example:

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

You cannot use such feature in older device. Those API (some from android.security.keystore) are available only on Android M

Annapurna answered 15/2, 2016 at 10:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.