How to Use Unsupported Exception for Lower Platform Version

后端 未结 3 1201
渐次进展
渐次进展 2020-12-16 00:42

I have a DialogFragment that handles login and fingerprint authentication for my application. This fragment uses two classes that are exclusive to API 23,

3条回答
  •  再見小時候
    2020-12-16 01:05

    As you said the problem is with that catch block

    catch (KeyPermanentlyInvalidatedException exception) {
        Timber.w(exception, "A new fingerprint was added to the device");
        handleKeyPermanentlyInvalidated();
        return false;
    }
    

    Because that exception is added on API LEVEL 23, but I don't know why the verify error is thrown at initialization time itself.

    Anyway you can catch the exception using

    catch (InvalidKeyExceptionexception) {
        ....
        return false;
    }
    

    since KeyPermanentlyInvalidatedException extends InvalidKeyExceptionexception

提交回复
热议问题