本文介绍了如何在低于Android 9.0的版本中使用Biometric Prompt API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实施生物识别提示API,以使用指纹验证来验证用户身份。我能够成功集成Biometric提示,并且它正在Andorid 9.0上运行。但是正如文档所示,Biometric api也向后兼容,但是当我使用以下代码构建对话框时,它会显示API支持警告。

I am trying to implement Biometric prompt API to authenticate user using fingerprint verification. I am successfully able to integrate Biometric prompt and it is working on andorid 9.0. But as the documentation suggests Biometric api is also backwards compatible, but when I build dialog using below code it shows API support warning.



mBiometricPrompt = new BiometricPrompt.Builder(this)
                        .setDescription("Description")
                        .setTitle("Title")
                        .setSubtitle("Subtitle")
                        .setNegativeButton("Cancel", getMainExecutor(), new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                Log.i(TAG, "Cancel button clicked");
                            }
                        })
                        .build();

如何在较低的api上实现此功能?这是截图。

What can I do to make this work on lower apis? Here is Screenshot.

推荐答案

类似于旧版本的生物特征提示API是仍处于alpha状态。如果您可以使用Alpha版本,则可以在 build.gradle

Looks like Biometric Prompt API for older version is still in alpha. If you are ok with an alpha version you can use this in build.gradle

compile group: 'androidx.biometric', name: 'biometric', version: '1.0.0-alpha02'

来源:

此处仅列出了两个版本


  • 1.0.0-alpha01

  • 1.0.0-alpha02

来源:

根据库描述,它说

这意味着您需要的只是这个兼容库,并且可以在所有版本的Android上使用。对于高于Android 9和低于Android 9的版本,无需保留两个不同的版本。

Which would mean that all you need is this compat library and it would work on all version of Android. No need to keep two different version for above Android 9 and below Android 9.

这篇关于如何在低于Android 9.0的版本中使用Biometric Prompt API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 09:02