Android11biometric验证回调函数在通过按下返回键关闭前一个提示后不会触发。
创始人
2024-08-20 10:00:14
0

出现上述问题可能是因为在验证时没有正确处理结果回调。要解决这个问题,可以使用以下代码例子,判断回调结果,当用户按下返回键关闭前一个提示时,手动调用cancel()函数取消验证:

if (BiometricPrompt.AUTHENTICATION_RESULT_TYPE_ERROR == authenticationResult.getAuthenticationType( )) {
    biometricPrompt.cancelAuthentication( );
}

此外,还可以使用以下代码例子,将onAuthenticationError()函数用于取消出现上述问题的验证:

biometricPrompt = new BiometricPrompt.Builder(activity)
    .setTitle(title)
    .setNegativeButton(negativeButtonText, executor, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            authenticationCallback.onCancelled( );
            dialog.dismiss( );
        }
    })
    .build( );

biometricPrompt.authenticate(promptInfo, new BiometricPrompt.CryptoObject(yourCipher), executor, authenticationCallback);

private class AuthenticationCallback extends BiometricPrompt.AuthenticationCallback {
 
    @Override
    public void onAuthenticationError(int errorCode, @NonNull CharSequence errString) {
        super.onAuthenticationError(errorCode, errString);
        if (errorCode == BiometricPrompt.ERROR_USER_CANCELED) {
            onCancelled( );
        }
    }
 
    @Override
    public void onAuthenticationFailed() {
        super.onAuthenticationFailed( );
    }
 
    @Override
    public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationResult result) {
        super.onAuthenticationSucceeded(result);
        onSuccess( );
    }
 
    public void onSuccess( ) {
        //do something after authentication success
    }
     
    public void onCancelled( ) {
        //do something after authentication cancelled
    }
}

相关内容

热门资讯

最新研发!来玩德州app外挂(... 最新研发!来玩德州app外挂(辅助挂)果真是真的有挂(详细教程)(有挂总结)-哔哩哔哩;揭秘教程安装...
透明攻略!传奇扑克辅助(辅助挂... 透明攻略!传奇扑克辅助(辅助挂)果真真的有挂(详细教程)(有挂规律)-哔哩哔哩关于传奇扑克辅助的基本...
透视辅助(来玩德州app有挂)... 透视辅助(来玩德州app有挂)辅助透视(辅助挂)的确真的有挂(有挂总结)-哔哩哔哩;来玩德州app有...
一分钟了解!德扑ai操作(透视... 大家肯定在之前德扑ai操作或者德扑ai操作中玩过一分钟了解!德扑ai操作(透视)确实真的有挂(详细教...
我来教教大家!哈糖大菠萝拿好牌... 我来教教大家!哈糖大菠萝拿好牌,欢乐棋牌有挂,确实是真的有挂(有挂教学)-哔哩哔哩1、让任何用户在无...
透视代打(fishpoker下... 透视代打(fishpoker下载)软件透明挂(辅助挂)原来是真的有挂(有挂攻略)-哔哩哔哩准备好在f...
重大通报!德州ai辅助app(... 重大通报!德州ai辅助app(辅助挂)其实真的有挂(详细教程)(有挂总结)-哔哩哔哩1、点击下载安装...
重大通报!德州nzt实战,云扑... 重大通报!德州nzt实战,云扑克确实真的有挂,确实真的有挂(有挂技巧)-哔哩哔哩;亲真的是有正版授权...
透视系统!poker辅助工具(... 1、透视系统!poker辅助工具(辅助挂)确实是真的有挂(详细教程)(有挂详情)-哔哩哔哩(UU p...
分享开挂内幕!德州wpk辅助真... 分享开挂内幕!德州wpk辅助真的(透视)其实真的有挂(详细教程)(有挂总结)-哔哩哔哩关于德州wpk...