缺少 BiometricPromptCompat
BiometricPromptCompat is missing
Android P 对 Biometrics API
进行了更改。
现在我们应该使用 BiometricPrompt
class 在我们的应用程序中集成生物认证(FingerprintManager
已弃用)。
问题是此 class 仅在 API 28 可用。
A support library is also provided for devices running Android O and earlier, allowing applications to utilize the advantages of this API across more devices .
但是我找不到那个支持库。
它存在吗?还是会在以后的实现中加入?
我认为在您提出问题时, 丢失了。 1.0.0-alpha01
于 9 月发布。目前最新版本是 1.0.0-alpha02
.
将此添加到您的 build.gradle:
implementation 'androidx.biometric:biometric:1.0.0-alpha02'
正如@JayShortway 回答的那样,向后兼容的依赖项是:
implementation 'androidx.biometric:biometric:1.0.0-alpha02'
但实现与android.hardware.biometrics.BiometricPrompt
实现不同:
class BiometricsManagerImpl {
private val executor = MainThreadExecutor()
override fun authenticate(activity: FragmentActivity) {
val prompt = BiometricPrompt(
activity,
executor,
object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
super.onAuthenticationError(errorCode, errString)
// Handle authentication errors
}
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
// Authentication Succeeded
}
})
val promptInfo = BiometricPrompt.PromptInfo.Builder()
.setTitle("Biometric Authentication")
.setDescription("Please authenticate in order to verify your identity")
.setNegativeButtonText("Cancel")
.build()
prompt.authenticate(promptInfo)
}
inner class MainThreadExecutor : Executor {
private val handler = Handler(Looper.getMainLooper())
override fun execute(runnable: Runnable) {
handler.post(runnable)
}
}
}
Android P 对 Biometrics API
进行了更改。
现在我们应该使用 BiometricPrompt
class 在我们的应用程序中集成生物认证(FingerprintManager
已弃用)。
问题是此 class 仅在 API 28 可用。
A support library is also provided for devices running Android O and earlier, allowing applications to utilize the advantages of this API across more devices .
但是我找不到那个支持库。
它存在吗?还是会在以后的实现中加入?
我认为在您提出问题时, 丢失了。 1.0.0-alpha01
于 9 月发布。目前最新版本是 1.0.0-alpha02
.
将此添加到您的 build.gradle:
implementation 'androidx.biometric:biometric:1.0.0-alpha02'
正如@JayShortway 回答的那样,向后兼容的依赖项是:
implementation 'androidx.biometric:biometric:1.0.0-alpha02'
但实现与android.hardware.biometrics.BiometricPrompt
实现不同:
class BiometricsManagerImpl {
private val executor = MainThreadExecutor()
override fun authenticate(activity: FragmentActivity) {
val prompt = BiometricPrompt(
activity,
executor,
object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
super.onAuthenticationError(errorCode, errString)
// Handle authentication errors
}
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
// Authentication Succeeded
}
})
val promptInfo = BiometricPrompt.PromptInfo.Builder()
.setTitle("Biometric Authentication")
.setDescription("Please authenticate in order to verify your identity")
.setNegativeButtonText("Cancel")
.build()
prompt.authenticate(promptInfo)
}
inner class MainThreadExecutor : Executor {
private val handler = Handler(Looper.getMainLooper())
override fun execute(runnable: Runnable) {
handler.post(runnable)
}
}
}