当手动请求Oreo指纹识别权限时,弹出框没有显示。
我在清单文件中列出了USE_FINGERPRINT权限,但仍然出现异常:
W/System.err: java.lang.SecurityException: Must have android.permission.USE_FINGERPRINT permission.: Neither user 10190 nor current process has android.permission.USE_FINGERPRINT.
at android.os.Parcel.readException(Parcel.java:2004)
at android.os.Parcel.readException(Parcel.java:1950)
at android.hardware.fingerprint.IFingerprintService$Stub$Proxy.isHardwareDetected(IFingerprintService.java:465)
at android.hardware.fingerprint.FingerprintManager.isHardwareDetected(FingerprintManager.java:835)
at ""ui.biometricAuth.BiometricAuth.getFingerPrintAuthError(BiometricAuth.java:174)
at ""ui.biometricAuth.BiometricAuth.isTouchIDEnabled(BiometricAuth.java:225)
at ""ui.usermanagement.LoginActivity.onCreate(LoginActivity.java:403)
at android.app.Activity.performCreate(Activity.java:7036)
at android.app.Activity.performCreate(Activity.java:7027)
W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1231)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2864)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2989)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6753)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:482)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
USE_FINGERPRINT
没有任何问题。例如,查看此项目 。我碰巧在指纹 API 的反应层上使用RxFingerprint
库,但这在这里并不重要。 - CommonsWarehasEnrolledFingerprints()
有时会在重新启动手机后第一次调用时引发SecurityException
。如果在hasEnrolledFingerprints
之前调用isHardwareDetected
,该问题似乎会消失,但为了安全起见,我将整个过程包装在try {} catch(SecurityException){}
中。 - Michael