应用程序内的Android Finger Print本地身份验证

时间:2016-10-03 08:59:24

标签: android

我需要使用指纹内的指纹对话验证用户以验证用户。I have tried this link 但是它显示此错误

  

至少注册一个指纹

虽然3个指纹已在设备中注册(三星s5 os marsmallow)

1 个答案:

答案 0 :(得分:0)

FingerprintManager类必需Android设备应该内置os 6.0否则isHardwareDetected()和hasEnrolledFingerprints()返回false S5 Android OS,v4.4.2(KitKat),可升级至v6.0(Marshmallow)

final FingerprintManager fingerprintManager = getSystemService(FingerprintManager.class);
        if(fingerprintManager.isHardwareDetected()) {
            if (fingerprintManager.hasEnrolledFingerprints()) {
                Toast.makeText(getApplicationContext(), "Device has FingerPrint", Toast.LENGTH_LONG).show();
            }


            fingerprintManager.authenticate(new FingerprintManager.CryptoObject(criper),mCancellationSignal , 0, new FingerprintManager.AuthenticationCallback() {
                @Override
                public void onAuthenticationError(int errorCode, CharSequence errString) {
                    super.onAuthenticationError(errorCode, errString);
                    Toast.makeText(getApplicationContext(), "FingerPrint Not Registered", Toast.LENGTH_LONG).show();
                    dialogue.dismiss();
                    mCancellationSignal.cancel();

                }

                @Override
                public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
                    super.onAuthenticationSucceeded(result);
                    Toast.makeText(getApplicationContext(), "Authentication Successful", Toast.LENGTH_LONG).show();
                    loginRequest(false);
                    mManage.setStringValue("name",emailtxt.getText().toString());
                    mManage.setStringValue("pass",passwordtxt.getText().toString());
                    mManage.setBooleanValue("TouchID",true);
                    dialogue.dismiss();
                }
            }, null);
        }