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

相关内容

热门资讯

一分钟了解!哈局十三张怎么提高... 一分钟了解!哈局十三张怎么提高胜率,红龙扑克是有问题(详细透视辅助插件教程)相信很多朋友都在电脑上玩...
9分钟教学!心悦麻将神器,微扑... 9分钟教学!心悦麻将神器,微扑克可以用ai辅助(详细透视辅助器教程);玩家必备必赢加哟《136704...
8分钟介绍!河北微乐麻将挂,微... 8分钟介绍!河北微乐麻将挂,微扑克脚本代写(详细透视辅助插件教程)1、许多玩家不知道河北微乐麻将挂辅...
8分钟详情!天酷棋牌有挂吗,线... 8分钟详情!天酷棋牌有挂吗,线上德州ai智能机器人(详细透视辅助工具教程)这是由厦门游乐互动科技有限...
2分钟方法!永州扯胡子辅助软件... 2分钟方法!永州扯胡子辅助软件,约局吧有辅助(详细透视辅助app教程);人气非常高,ai更新快且高清...
两分钟规律!四川游戏家园万能辅... 两分钟规律!四川游戏家园万能辅助工具,微扑克透明挂(详细透视辅助助手教程);四川游戏家园万能辅助工具...
三分钟教程!蒙乐呼伦贝尔有挂吗... 您好,蒙乐呼伦贝尔有挂吗这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩家...
1分钟方法!中至余干可以设置输... 1分钟方法!中至余干可以设置输赢吗,wepoke软件收费(详细透视辅助黑科技教程)1、不需要AI权限...
5分钟教程!丽水茶苑有外 挂是... 1、5分钟教程!丽水茶苑有外 挂是真的吗,gg扑克平台发牌机制(详细透视辅助软件教程);该软件可以轻...
9分钟方法!雀友辅助软件,wp... 9分钟方法!雀友辅助软件,wpk外 挂是真的还是假的(详细透视辅助挂教程)关于雀友辅助软件的基本介绍...