首页 > 解决方案 > Fingerprint API 如何知道它已被调用?

问题描述

我正在尝试学习如何实现指纹 API。

在其中一个指纹指南中,它给了我一个代码

@RequiresApi(api = Build.VERSION_CODES.P)
public class BiometricCallbackV28 extends BiometricPrompt.AuthenticationCallback {

    private BiometricCallback biometricCallback;
    public BiometricCallbackV28(BiometricCallback biometricCallback) {
        this.biometricCallback = biometricCallback;
    }


    @Override
    public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
        super.onAuthenticationSucceeded(result);
        biometricCallback.onAuthenticationSuccessful();
    }


    @Override
    public void onAuthenticationHelp(int helpCode, CharSequence helpString) {
        super.onAuthenticationHelp(helpCode, helpString);
        biometricCallback.onAuthenticationHelp(helpCode, helpString);
    }


    @Override
    public void onAuthenticationError(int errorCode, CharSequence errString) {
        super.onAuthenticationError(errorCode, errString);
        biometricCallback.onAuthenticationError(errorCode, errString);
    }


    @Override
    public void onAuthenticationFailed() {
        super.onAuthenticationFailed();
        biometricCallback.onAuthenticationFailed();
    }
}

但是不应该测试身份验证是否通过 THEN 调用 onAuthenticationSucceeded 吗?我没有看到任何地方调用 public void onAuthenticationSucceeded。它怎么知道指纹匹配?谁调用方法?

标签: androidandroid-fingerprint-api

解决方案


但是不应该有一个验证是否通过的测试

系统通过将扫描的指纹与用户注册的指纹进行比较来知道认证是否通过

我没有看到任何地方调用 public void onAuthenticationSucceeded

该框架会根据生物识别硬件的结果调用所有这些回调方法。


推荐阅读