Android提示DeviceCredentialHandler:onCreate:Executor和/或回调为空

Android提示DeviceCredentialHandler:onCreate:Executor和/或回调为空,android,react-native,android-biometric-prompt,Android,React Native,Android Biometric Prompt,看起来1.0.0有一个bug,它一直处于不可见状态,引发异常 我会在答案中提出解决办法 编辑(感谢@Isai Damier): 复制方式: 打开提示 按后退按钮-关闭提示 再次按back并退出应用程序 返回应用程序-再次尝试打开提示 当生物识别提示版本为1.0.0时引入此修复程序。本期dosent在1.0.1版中复制 //------------------------------------------------------------------------- 我想出了一个变通办法——在用

看起来1.0.0有一个bug,它一直处于不可见状态,引发异常

我会在答案中提出解决办法

编辑(感谢@Isai Damier):

复制方式:

  • 打开提示
  • 按后退按钮-关闭提示
  • 再次按back并退出应用程序
  • 返回应用程序-再次尝试打开提示

  • 当生物识别提示版本为1.0.0时引入此修复程序。本期dosent在1.0.1版中复制

    //-------------------------------------------------------------------------

    我想出了一个变通办法——在用户取消时提示“cancelAuthentication”

    完整代码如下(用于react本机应用程序-这就是承诺的原因):


    我希望它对任何人都有帮助-干杯

    嗨!我尝试了您的解决方案,但它不起作用…但如果您在onAuthenticationError()和OnAuthenticationSuccessed()中包含recreate()方法,则效果会非常好!!很好,我会尝试一下并重新发布OK,现在我在您编写“重新创建”时得到了它-我不想影响活动生命周期-我只想打开关闭重新打开提示-这就是我首先保存
    bp
    的原因。无论如何,谢谢@fesave这个问题没有说明bug是什么。重新创建错误的步骤是什么?
        private const val E_BIOMETRIC_ERR = "E_FINGER_PRINT_ERR"
        private const val OPENED = "success"
        private var bp: BiometricPrompt? = null
        private var mAuthenticationPromise: Promise? = null
    
        fun authenticate(activity: AppCompatActivity, title: String,
                         subTitle: String, description: String, authenticationPromise: Promise) {
            mAuthenticationPromise = authenticationPromise
    
            val executor = Executors.newSingleThreadExecutor()
    
            bp?.cancelAuthentication()
            bp = getBiometricPrompt(activity, executor)
    
            val promptInfo = BiometricPrompt.PromptInfo.Builder()
                    .setTitle(title)
                    .setSubtitle(subTitle)
                    .setDescription(description)
                    .setDeviceCredentialAllowed(true)
                    .build()
    
            bp!!.authenticate(promptInfo)
    
        }
    
    
    
        private fun getBiometricPrompt(activity: AppCompatActivity, executor: Executor): BiometricPrompt {
            return BiometricPrompt(activity, executor, object : BiometricPrompt.AuthenticationCallback() {
    
                override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
                    super.onAuthenticationSucceeded(result)
                    mAuthenticationPromise?.resolve(OPENED)
                }
    
                override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
                    super.onAuthenticationError(errorCode, errString)
                    bp!!.cancelAuthentication()
                }
    
                override fun onAuthenticationFailed() {
                    super.onAuthenticationFailed()
                    bp!!.cancelAuthentication()
                }
            })
        }