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

相关内容

热门资讯

透视好牌!智星德州可以透视吗,... 透视好牌!智星德州可以透视吗,约局吧能不能开挂,攻略教程(有挂攻略);1、在智星德州可以透视吗ai机...
透视存在!德普之星透视软件免费... 透视存在!德普之星透视软件免费入口官网,(德扑之心)一贯是真的有挂,wpk教程(有挂脚本);1、德普...
透视存在!werplan怎么作... 透视存在!werplan怎么作弊,约局吧作弊脚本,爆料教程(有挂细节)1.约局吧作弊脚本 ai辅助创...
透视辅助!德普之星辅助器怎么用... 透视辅助!德普之星辅助器怎么用,(德普)真是存在有挂,细节揭秘(有挂工具)1、德普之星辅助器怎么用a...
透视了解!pokemmo脚本手... 透视了解!pokemmo脚本手机版,聚星ai辅助工具收费多少,黑科技教程(有挂插件)所有人都在同一条...
透视脚本!德普之星透视辅助,(... 透视脚本!德普之星透视辅助,(德普之星)好像是有挂,wepoke教程(有挂脚本)运德普之星透视辅助辅...
透视存在“werplan脚本”... 透视存在“werplan脚本”透视辅助器(果然有挂);1.werplan脚本 ai辅助创建新账号,点...
透视辅助!德普之星私人局辅助免... 透视辅助!德普之星私人局辅助免费,德普之星辅助器app,揭秘教程(有挂方法)德普之星私人局辅助免费辅...
透视教学“cloudpoker... 透视教学“cloudpoker怎么开挂”透视辅助助手(一贯有挂);1、打开软件启动之后找到中间准星的...
透视计算“大菠萝免费辅助”透视... 透视计算“大菠萝免费辅助”透视辅助器(好像有挂)1、大菠萝免费辅助系统规律教程、大菠萝免费辅助辅助透...