我可以为我的android应用添加指纹支持。因此,这是第一次要求指纹验证并解锁应用程序。但是,当屏幕在首次身份验证后锁定时,它将不再要求再次进行身份验证。我该怎么办?每当他尝试访问应用程序时,我都需要询问用户身份验证。不仅是第一次。代码如下。这是简单的代码。如果通过身份验证,请加载另一个片段。我只想在屏幕超时时锁定应用程序。
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
if (!fingerprintManager.isHardwareDetected()){
//Fingerpring scanner not detected
}else if(ContextCompat.checkSelfPermission(this,Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED){
//Permission not granted to use fingerprint scanner
}else if(!keyguardManager.isKeyguardSecure()){
//Add lock in your phone locking
}else if(!fingerprintManager.hasEnrolledFingerprints()){
//Add at least one fingerprint
}else{
FingerPrintHelper fingerPrintHelper = new FingerPrintHelper(this);
fingerPrintHelper.startAuth(fingerprintManager,null);
startActivity(new Intent(FingerPrintActivity1.this, LoginActivity.class));
}
}