Android M FingerprintManager.isHardwareDetected()在Samsung Galaxy S5上返回false [英] Android M FingerprintManager.isHardwareDetected() returns false on a Samsung Galaxy S5

查看:133
本文介绍了Android M FingerprintManager.isHardwareDetected()在Samsung Galaxy S5上返回false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚通过当我运行下面的代码时,isHardwareDetected()返回'false'.我希望它返回"true".

When I run the code below, isHardwareDetected() returns 'false'. I would expect it to return 'true'.

我完成的谷歌搜索并没有产生关于棉花糖支持S5指纹读取器的任何一种信息.

The Googling I have done does not resulted in any information one way or the other as to the S5 fingerprint reader being supported under Marshmallow.

有人支持S5的指纹读取器吗?

Does anyone have any information about the S5's fingerprint reader being supported?

    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);
    }

推荐答案

最终解决.看来android默认API无法处理某些Samsung设备,因此解决方案是为此问题添加Samsung库.

Finally solved. It looks like android default API is not able to handle some Samsung devices, so the solution is to add the Samsung libraries for this issue.

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

You can find some documentation and the libraries here: http://developer.samsung.com/galaxy/pass

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

After add the libraries, you have to add a new permission to your manifest:

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

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

And finally, you could use this method:

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;
}

这篇关于Android M FingerprintManager.isHardwareDetected()在Samsung Galaxy S5上返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆