Android M FingerprintManager.isHardwareDetected()在Samsung Galaxy S5

时间:2016-06-21 05:04:08

标签: android

我刚刚通过http://www.androidofficer.com/2016/06/g900vvru2dpd1-android-601-marshmallow.html

中列出的手册说明将Verizion Samsung Galaxy S5(SM-G900V)更新为G900VVRU2DPD1版本

当我运行下面的代码时,isHardwareDetected()返回'false'。我希望它能回归'真实'。

我所做的谷歌搜索没有以任何方式获得有关Marshmallow支持的S5指纹识别器的任何信息。

是否有人有关于支持S5指纹识别器的任何信息?

    FingerprintManager manager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
    if (manager != null) {

        if (ActivityCompat.checkSelfPermission(this, permission.USE_FINGERPRINT) !=
                PackageManager.PERMISSION_GRANTED) {
            retVal.append(INDENT).append("Fingerprint permission was not granted")
                    .append(EOL);
        } else {
            retVal.append(INDENT).append("Fingerprint hardware detected: ")
                    .append(manager.isHardwareDetected()).append(EOL);
            retVal.append(INDENT).append("Has Enrolled Fingerprint(s): ")
                    .append(manager.hasEnrolledFingerprints()).append(EOL);
        }
    } else {
        retVal.append(INDENT).append("no FingerprintManager available").append(EOL);
    }

1 个答案:

答案 0 :(得分:10)

终于解决了。看起来Android默认API无法处理某些三星设备,因此解决方案是为此问题添加三星库。

您可以在此处找到一些文档和库:http://developer.samsung.com/galaxy/pass

添加库后,您必须向清单添加新权限:

<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY" />

最后,您可以使用此方法:

private boolean isFingerprintSupported() {
  boolean isFingerprintSupported = fingerprintManager != null && fingerprintManager.isHardwareDetected();
  if (!isFingerprintSupported && SsdkVendorCheck.isSamsungDevice()) {
    Spass spass = new Spass();
    try {
        spass.initialize(context);
        isFingerprintSupported = spass.isFeatureEnabled(Spass.DEVICE_FINGERPRINT);
    } catch (SsdkUnsupportedException | UnsupportedOperationException e) {
        // Error handling
    }
  }
  return isFingerprintSupported;
}