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