简体   繁体   English

使用生物识别 androidX 库 1.1.0 崩溃

[英]Crash using biometric androidX library 1.1.0

In my app, I'm using androidX biometric support library 1.1.0.在我的应用程序中,我使用的是 androidX 生物识别支持库 1.1.0。 On all Android versions, my app is crashing.在所有 Android 版本上,我的应用程序都崩溃了。 Here is the code snippet that I have used这是我使用的代码片段

Exception:例外:

java.lang.IllegalStateException: Must be called from main thread of fragment host java.lang.IllegalStateException: 必须从片段宿主的主线程调用

In:在:

public boolean isFingerprintAuthAvailable(Context mContext) {
        BiometricManager biometricManager = BiometricManager.from(mContext);
        if (biometricManager.canAuthenticate() == BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE) {
            return false;
        } else if (biometricManager.canAuthenticate() == BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE) {
            return false;
        } else if (biometricManager.canAuthenticate() == BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED) {
            return false;
        } else if (biometricManager.canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS) {
            return true;
        }
        return false;
    }

BiometricPrompt.PromptInfo promptInfo = new BiometricPrompt.PromptInfo.Builder()
                    .setTitle("fingerPrintTitle")
                    .setDescription("Description")
                    .setNegativeButtonText(""negative text")
                    .build();

 if (isFingerprintAuthAvailable(mContext)) {
        mBiometricPrompt.authenticate(promptInfo, cryptoObject);
 }

I have moved the code to UI thread我已将代码移至 UI 线程

runOnUiThread(new Runnable() {
            @Override
            public void run() {
                mBiometricPrompt.authenticate(promptInfo, cryptoObject);
            }
        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用生物识别 androidx 库时崩溃 - Crash using biometric androidx library 如果仅安装了面部作为生物特征,则使用 AndroidX.Biometric 的 KeyGeneration 会失败 - KeyGeneration using AndroidX.Biometric fails if only face as biometric is installed 在 Android 中使用 androidx Biometric API 进行人脸认证 - Face Authentication using androidx Biometric API in Android 使用AndroidX生物识别最新版本进行身份验证会导致崩溃[Android] - Authenticating with AndroidX biometric latest version causes crash [Android] 检测androidx生物识别库中是否添加或删除了新指纹 - Detect if new finger print added or removed in androidx biometric library 当从属库使用AndroidX库时,使用Android支持库的Android Project崩溃 - Android Project using Android Support libraries crash, when a dependant library uses AndroidX library 在 Android 7 上实现 androidx 生物识别库后,字体缩放不起作用 - Font scaling doesn't work after implementing androidx biometric library on Android 7 使用 androidx 生物识别提示检查设备是否启用了生物识别 - Check if devices has biometric enabled with androidx biometric prompt 库应该使用androidx还是android.support? - Should library be using androidx or android.support? 更新到片段测试库v1.1.0-alpha03后崩溃 - Crash after updating to Fragment Testing library v1.1.0-alpha03
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM