我androidx.biometric:biometric:1.0.0-alpha03
在测试项目中使用,并且在推送时negative button
总是收到以下错误消息:
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)
我认为这是一个需要修复的库问题,因为片段似乎为空,或者我在这里做错了什么?
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)