我使用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)