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
    }
}

相关内容

热门资讯

wepoke真的有挂!德州wp... wepoke真的有挂!德州wpk德州真的,(WepOke)固有真的有挂(详细透视透明教程);wepo...
wepoke确实有挂!wpk透... 1、wepoke确实有挂!wpk透视辅助可测试,(aApoker)最初存在有挂(详细辅助玩家教程);...
微扑克ai辅助器苹果版!德扑之... 微扑克ai辅助器苹果版!德扑之星能看到底牌吗,(wEpoKe)往昔有挂(详细透视2025新版总结);...
透视工具(微扑克ai机器人)w... 透视工具(微扑克ai机器人)wpk微扑克智能辅助(详细辅助必胜教程)先前真的是有挂1、超多福利:超高...
透视插件(wepoke有没有挂... 透视插件(wepoke有没有挂)智星德州扑克辅牌器(详细辅助AI教程)一向有挂1)辅助挂:进一步探索...
德州之星辅助挂!德州数据辅助器... 德州之星辅助挂!德州数据辅助器,(AAPOKEr)确实真的是有挂(详细透视新版2025教程) 科技详...
智星德州菠萝偷偷看牌功能!aa... 智星德州菠萝偷偷看牌功能!aapoker安卓怎么下载,(wpK)一向真的是有挂(详细透视线上教程);...
透视教学(aapoker有猫腻... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩家在这款游戏中打牌都...
WePoKe外挂!德州ai智能... 1、WePoKe外挂!德州ai智能辅助,(wEPoke)竟然是有挂(详细透视教你攻略)。2、WePo...
透视app(德州AI智能辅助机... 透视app(德州AI智能辅助机器人)微扑克有挂吗(详细辅助必胜教程)原先有挂;一、AI软件牌型概率发...