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

相关内容

热门资讯

教学盘点!wpk可以辅助吗,w... 教学盘点!wpk可以辅助吗,wepoker有机器人吗,必赢方法(一贯确实有挂)-哔哩哔哩;wepok...
玩家必看科普!德普之星透视辅助... 玩家必看科普!德普之星透视辅助软件,hhpoker辅助挂下载,我来教教你(其实是有挂的)-哔哩哔哩;...
透视有挂!wejoker辅助脚... 透视有挂!wejoker辅助脚本,we poker辅助器v3.3,细节揭秘(一直确实有挂)-哔哩哔哩...
重大通报!wepoker亲友圈... 重大通报!wepoker亲友圈有用吗,wpk俱乐部怎么辅助,规律教程(果然是有挂的)-哔哩哔哩;亲真...
必备科技!德普之星有辅助软件吗... 必备科技!德普之星有辅助软件吗,hhpoker是内部控制吗,详细教程!(一直确实有挂)-哔哩哔哩;人...
揭秘关于!德州局hhpoker... 揭秘关于!德州局hhpoker,wepoker有人用过吗,线上教程(一贯真的有挂)-哔哩哔哩;超受欢...
必备辅助推荐!wepoker破... 《必备辅助推荐!wepoker破解游戏盒子,aapoker插件下载,揭秘教程(原来有挂)-哔哩哔哩》...
我来分享!wepoker私人局... 我来分享!wepoker私人局透视插件,wepoker轻量版有透视吗,2026版教程(原来真的有挂)...
透视规律!aapoker如何设... 透视规律!aapoker如何设置胜率,德州透视竞技联盟,2026教程(原来是有挂的)-哔哩哔哩;1、...
实测教程!哈糖大菠萝有挂吗5个... 实测教程!哈糖大菠萝有挂吗5个常用方法,pokeplus脚本,黑科技教程(一直真的是有挂)-哔哩哔哩...