android - 如何使 BiometricPrompt 不可取消?
问题描述
我BiometricPrompt
在我的应用程序中使用。authenticate()
它运行良好,并在调用该方法时显示对话框。但是当我在对话框外部单击时,此对话框会关闭。如何预防?如何使 BiometricPrompt 的对话框不可取消?这里没有像biometricPrompt.setCancelable(false)
.
解决方案
BiometricPrompt
不允许这样做。因此,您将无法将系统提供的生物识别提示设为不可取消。但是您可以检测到用户何时取消对话框。
所以一个选项是,在用户取消后再次显示生物识别提示(我认为这将是一个糟糕的用户体验)或使用备用用户身份验证:
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
if (errorCode == BiometricConstants.ERROR_USER_CANCELED) {
// User canceled the operation
// you can either show the dialog again here
// or use alternate authentication (e.g. a password) - recommended way
}
}
推荐阅读
- python - 需要在 R 中生成 5000 个均值
- google-colaboratory - tensorflow 2 google colab 教程中的问题
- java - 无法从 START_OBJECT 令牌中反序列化 `java.lang.Long` 的实例;在 Spring Boot 帖子上
- python - 如何让蛇继续朝那个方向前进,直到按下另一个箭头键
- powershell - Power BI 管理的 Powershell 脚本在标准 PS 终端中不起作用
- linux - 需要有关使用嵌套命令替代的建议
- r - 在 R 中为多个绘图包含更多空间
- python - 如何应用切片窗口将熊猫转换为二维数组?
- javascript - 如何使用 Jest 测试反应组件,该组件映射到对象数组以匹配设置要呈现的值的对象值
- javascript - 在 NextJS 中让 styled-jsx 与 tailwindcss 一起工作