Jetpack的BiometricPrompt(androidx.biometric.BiometricPrompt)引发NullPointerException [英] Jetpack's BiometricPrompt (androidx.biometric.BiometricPrompt) throws NullPointerException

查看:313
本文介绍了Jetpack的BiometricPrompt(androidx.biometric.BiometricPrompt)引发NullPointerException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在测试项目中使用 androidx.biometric:biometric:1.0.0-alpha03 并按负按钮我总是收到以下错误消息:

I'm using androidx.biometric:biometric:1.0.0-alpha03 in a test project and when pushing the negative button I always get the following error message:

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence androidx.biometric.BiometricFragment.getNegativeButtonText()' on a null object reference
    at androidx.biometric.BiometricPrompt$1$1.run(BiometricPrompt.java:329)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)

我认为这是一个库问题,需要解决,因为该片段似乎为空还是我在这里做错了什么?

I think this is a library issue which needs to be fixed as the fragment seems to be null or is there anything I'm doing wrong here?

val prompt = BiometricPrompt(activity, Executors.newSingleThreadExecutor(), object : BiometricPrompt.AuthenticationCallback() {
        override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {}
        override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {}
        override fun onAuthenticationFailed() {}
})

val promptInfo = BiometricPrompt.PromptInfo.Builder()
        .setTitle(title)
        .setSubtitle(subtitle)
        .setDescription(description)
        .setNegativeButtonText(activity.getString(android.R.string.cancel))
        .build()

prompt.authenticate(promptInfo)


推荐答案

据报道三个月前作为一个错误,并且已报告为已修复两个月前。但是,他们尚未发布新的工件。

This was reported three months ago as a bug, and it was reported as fixed two months ago. However, they have not yet released a fresh artifact.

该问题中有一些评论表明这是一个时机,添加延迟可以帮助解决方法。

There are some comments in that issue that suggest that "it's a timing thing", and that adding delays can help as a workaround.

这篇关于Jetpack的BiometricPrompt(androidx.biometric.BiometricPrompt)引发NullPointerException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆