Cancel Fingerprint scanner

徘徊边缘 提交于 2020-05-27 04:32:25

问题


I am working on a program that has a security function including a PIN and a fingerprint, but now I'm having a problem with entering the password (PIN or Fingerprint). Incorporating the correct fingerprints is fine, but when I enter the PIN code, after I exit the PIN and fingerprint activity, the machine continues to listen for fingerprints, I know this because when I click on the "home" button "The machine still vibrates slightly, so there is no way to stop listening to fingerprints?


回答1:


When you start up the fingerprint reader, you pass in a CancellationSignal.

When you want to cancel (maybe in the OnPause on your Activity), just call the cancel method of this object.

There is a complete sample here.




回答2:


You can cancel the Finger scan listener by using the CancellationSignal object. Check below code:

private CancellationSignal cancellationSignal;
...
...
public void startFingerAuth(FingerprintManager manager, FingerprintManager.CryptoObject cryptoObject) {
    if (ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT)
            != PackageManager.PERMISSION_GRANTED) {
        return;
    }
    cancellationSignal = new CancellationSignal();
    manager.authenticate(cryptoObject, cancellationSignal, 0, this, null);
}


public void stopFingerAuth(){
    if(cancellationSignal != null && !cancellationSignal.isCanceled()){
        cancellationSignal.cancel();
    }
}

You have to call this method stopFingerAuth() in your activity or fragment.



来源:https://stackoverflow.com/questions/43975602/cancel-fingerprint-scanner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!