xamarin.android - 为什么 Xamarin Android 中的 BiometricPrompt API 不包含 onAuthenticationError 回调
问题描述
在 Android Studios 中,BiometricPrompt API 包含一个名为 onAuthenticationError 的回调,当用户在 BiometricPrompt 对话框之外触摸以及用户尝试向设备输入无效的 Biometric 时,就会触发该回调。但 Xamarin.Android 平台中可用的 BiometricPrompt API 不提供 onAuthenticationError 回调。
我使用 Android Studios 创建了一个 android 应用程序来检查 BiometricPrompt API,在那里我可以访问名为 onAuthenticationError 的回调。然后我将应用程序部署到设备并调试应用程序。当我触摸 BiometricPrompt 对话框之外的任何区域时,就会触发上述回调,并且每次我向 BiometricPrompt 提供超过 5 次无效输入时也会触发它。然后我尝试在 Xamain.Android 中开发相同的应用程序,但在那里我找不到任何名为 onAuthenticationError 的回调。当我在设备中部署和测试应用程序时,因为上述回调不可用,我不能
我的本机 android 代码片段。
@RequiresApi(api = Build.VERSION_CODES.P)
private BiometricPrompt.AuthenticationCallback getAuthenticationCallback() {
return new BiometricPrompt.AuthenticationCallback() {
@Override
** public void onAuthenticationError(int errorCode,
CharSequence errString) {
notifyUser("Authentication error: " + errString);
super.onAuthenticationError(errorCode, errString);
}**
@Override
public void onAuthenticationHelp(int helpCode,
CharSequence helpString) {
super.onAuthenticationHelp(helpCode, helpString);
}
@Override
public void onAuthenticationFailed() {
super.onAuthenticationFailed();
}
@Override
public void onAuthenticationSucceeded(
BiometricPrompt.AuthenticationResult result) {
notifyUser("Authentication Succeeded");
super.onAuthenticationSucceeded(result);
}
};
}
我的 Xamarin.Android 代码片段
public class BiometricAuthCallBacks : BiometricPrompt.AuthenticationCallback
{
public TaskCompletionSource<LocalAuthStatus> promise = new TaskCompletionSource<LocalAuthStatus>();
private int failCount;
public override void OnAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result)
{
base.OnAuthenticationSucceeded(result);
promise.TrySetResult(LocalAuthStatus.Success);
//Success(result);
}
public override void OnAuthenticationFailed()
{
base.OnAuthenticationFailed();
failCount++;
if (failCount>=5)
{
promise.TrySetResult(LocalAuthStatus.Fail);
}
//Failed();
}
public override void OnAuthenticationHelp([GeneratedEnum] BiometricAcquiredStatus helpCode, ICharSequence helpString)
{
base.OnAuthenticationHelp(helpCode, helpString);
promise.TrySetResult(LocalAuthStatus.Error);
//Help(helpCode, helpString);
}
}
我的问题是为什么我不能从 Xamarin.Android 平台访问 onAuthenticationError 回调,我该如何解决这个问题?
解决方案
推荐阅读
- javascript - 如何在我的应用程序后台每 X 秒记录一次控制台日志?
- python - 在 Alembic 迁移升级期间是否可以连接到另一个数据库?
- regex - 在 PostgreSQL 中匹配部分反向引用
- java - 如何在指定相对路径的 Netbeans 项目中添加 .jar 文件
- php - 我需要帮助弄清楚为什么 Google reCAPTCHA 无法处理我网站的 .php 联系表
- excel - 如何检查用户是否在 VBA (Excel) 中登录 Cisco NetAccess?
- sql - 如何将共享相同外键的几行合并到列中?
- google-earth-engine - 从 Google 地球引擎导出 Sentinel-2 无云图像集
- python-3.x - 在 Python 中按列分组以获得总计数
- c++ - 类划分头和定义文件