在较低版本的Android上运行时出现问题

时间:2018-09-12 09:23:37

标签: android kotlin biometrics

在我的课堂上有很多有趣的事情:

main = withFile "index.html" WriteMode writeContents
  where writeContents file = mapM_ (hPutStrLn file) setHTML

尝试在P版本上运行都可以正常运行,它调用了有趣的@TargetApi(Build.VERSION_CODES.P) override fun showFingerprintDialog() { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) displayBiometricPrompt() else FingerprintDialog().show(supportFragmentManager, null) } @RequiresApi(Build.VERSION_CODES.P) private fun displayBiometricPrompt() { Log.d("some", "displayBiometricPrompt") val biometricPrompt = BiometricPrompt.Builder(AppResources.appContext) .setTitle("title") .setSubtitle("subTitle") .setDescription("description") .setNegativeButton("Cancel", AppResources.appContext?.mainExecutor, DialogInterface.OnClickListener { dialogInterface, i -> Log.d("some", "biometricPrompt") }) .build() val cancellationSignal = CancellationSignal() cancellationSignal.setOnCancelListener { Toast.makeText( AppResources.appContext, "onCancel", Toast.LENGTH_SHORT).show() } biometricPrompt.authenticate(cancellationSignal, AppResources.appContext?.mainExecutor, authenticationCallBack) } private val authenticationCallBack = object : BiometricPrompt.AuthenticationCallback() { override fun onAuthenticationError(errorCode: Int, errString: CharSequence?) { super.onAuthenticationError(errorCode, errString) Log.d("some", "onAuthenticationError") } override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult?) { super.onAuthenticationSucceeded(result) Log.d("some", "onAuthenticationSucceeded") } override fun onAuthenticationHelp(helpCode: Int, helpString: CharSequence?) { super.onAuthenticationHelp(helpCode, helpString) Log.d("some", "onAuthenticationHelp") } override fun onAuthenticationFailed() { super.onAuthenticationFailed() Log.d("some", "onAuthenticationFailed") } } ,然后在脚本中进一步运行,一切正常。 但是,如果我尝试在较低的版本上运行,则会引发以下错误,即在声明变量displayBiometricPrompt()时。

并得到下一个错误:

authenticationCallBack

0 个答案:

没有答案