【问题标题】:close prompt after three failure attempts in androidx biometric prompt?在androidx生物识别提示中尝试三次失败后关闭提示?
【发布时间】:2020-02-11 19:12:57
【问题描述】:

我在我的应用程序中使用 androidX 生物识别提示。我有三个查询,

  1. 在计算了三次失败尝试后,是否有关闭提示的选项。

  2. 是否有任何选项可以显示密码屏幕,而无需单击使用密码按钮(如果启用设备凭据为真)。

  3. 是否有自定义提示框的选项。

【问题讨论】:

  • 对于您的问题,请查看此answer,Q2 不清楚,Q3 您在默认提示中的自定义不可用。
  • @RahulGaur 对于 q1,androidX 生物识别提示没有取消信号选项(您提到的链接,使用取消信号)。 q2。在默认的生物识别提示中,我们可以选择使用密码(如果启用了设备凭据)。如果我们点击那个选项,上面的屏幕会出现对吗?是否有任何选项可以显示密码屏幕,而无需用户单击使用密码..

标签: android androidx android-biometric-prompt


【解决方案1】:
  1. 提示在 5 次尝试失败后自动关闭。 不过,您可以覆盖 BiometricCallback 并覆盖“onAuthenticationFailed”以计算失败次数

     override fun onAuthenticationFailed() {
            super.onAuthenticationFailed()
            //You can count the number of failed attempts, and call the cancellation signal here, onAuthenticationError will not be called if you do
     }
    
    override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
            super.onAuthenticationError(errorCode, errString)
            //explains to you in the errString why the authentication failed after *five* attempts
    
     }
    
  2. 我不确定,但我认为如果您显示提示,启用凭据为 true,则用户在提示“使用密码”上有一个按钮

   * The user will first be prompted to authenticate with biometrics, but also given the
   * option to authenticate with their device PIN, pattern, or password. Developers should
   * first check {@link KeyguardManager#isDeviceSecure()} before enabling this. If the device
   * is not secure, {@link BiometricPrompt#BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL} will be
   * returned in {@link AuthenticationCallback#onAuthenticationError(int, CharSequence)}}.
   * Defaults to false.
   *
   * Note that {@link #setNegativeButton(CharSequence, Executor,
   * DialogInterface.OnClickListener)} should not be set if this is set to true.
   *
   * @param allowed When true, the prompt will fall back to ask for the user's device
   *               credentials (PIN, pattern, or password).
   * @return
   */
  @NonNull public Builder setDeviceCredentialAllowed(boolean allowed) {
      mBundle.putBoolean(KEY_ALLOW_DEVICE_CREDENTIAL, allowed);
      return this;
  }

3. only the text on it

val prompt =
            BiometricPrompt.Builder(context).setTitle(title).setSubtitle(subtitleText).setDescription(description)
                .setNegativeButton(negativeButton, executor!!, cancelListener).build()

【讨论】:

  • 对于第二个答案,如果用户点击提示中的使用密码选项,那么只会出现密码屏幕对吗?? (如果启用了设备凭据)。是否有任何选项可以显示密码屏幕,而不显示提示..?
  • 我不这么认为,这太侵入性了,你想要一个锁定你设备的应用程序吗?
猜你喜欢
  • 2019-10-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-17
  • 2021-05-26
  • 2020-09-25
  • 1970-01-01
相关资源
最近更新 更多