如果指纹扫描器可用,让用户通过验证指纹来使用我的应用程序功能。
尝试使用以下代码:
FingerprintManager fingerprintManager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
if (!fingerprintManager.isHardwareDetected()) {
// Device doesn't support fingerprint authentication
} else if (!fingerprintManager.hasEnrolledFingerprints()) {
// User hasn't enrolled any fingerprints to authenticate with
} else {
// Everything is ready for fingerprint authentication
}
在PackageManager
实例上尝试hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)
(您可以通过在任何方便的Context
上调用getPackageManager()
来获取一个)。