Java 有没有办法检测手机上的手指触摸';指纹?

Java 有没有办法检测手机上的手指触摸';指纹?,java,android,Java,Android,我得到了身份验证码,它会在其中检查以前的指纹密钥是否可用,或者是否使用指纹管理器。但我只需要检测指纹上的触摸。当任何用户触摸时,进入下一个活动。我想检查指纹传感器是否正常工作。(无需验证检查)是否有解决方案 我已经试过了。但这不是我的解决方案。您可能需要在问题中添加一些代码示例。没有身份验证,您提供的链接的源代码不可用。我添加了身份验证代码。但这不是我真正需要的。我只需要检测手指触摸而不需要任何身份验证。您是否尝试使用authenticate方法及其callback参数?Afaik注册指纹似乎是

我得到了身份验证码,它会在其中检查以前的指纹密钥是否可用,或者是否使用指纹管理器。但我只需要检测指纹上的触摸。当任何用户触摸时,进入下一个活动。我想检查指纹传感器是否正常工作。(无需验证检查)是否有解决方案


我已经试过了。但这不是我的解决方案。

您可能需要在问题中添加一些代码示例。没有身份验证,您提供的链接的源代码不可用。我添加了身份验证代码。但这不是我真正需要的。我只需要检测手指触摸而不需要任何身份验证。您是否尝试使用
authenticate
方法及其
callback
参数?Afaik
注册指纹
似乎是指系统注册的指纹,这不是您要查找的。-另外,整个
密钥库
代码似乎与您的问题无关。是的。我只知道认证码。但我的问题的解决方案是什么??有什么方法可以检测触摸吗?问题是您将什么定义为
touch
。定义的帮助代码很少应发送到回调,例如:
FINGERPRINT\u ACQUIRED\u PARTIAL
。我假设您必须对其进行测试,以查看调用了什么回调。根据这一点,您应该能够判断传感器是否工作。即使是调用onAuthenticationFailed也会告诉您传感器正在工作。
     `// Check whether at least one fingerprint is registered
                       if (!fingerprintManager.hasEnrolledFingerprints()) {
                           textView.setText("Register at least one fingerprint in Settings");
                       }else{
                           // Checks whether lock screen security is enabled or not
                           if (!keyguardManager.isKeyguardSecure()) {
                               textView.setText("Lock screen security not enabled in Settings");
                           }else{
                               generateKey();
          initCipher();
         }
    protected void generateKey() {
           try {
               keyStore = KeyStore.getInstance("AndroidKeyStore");
           } catch (Exception e) {
               e.printStackTrace();
           }


           KeyGenerator keyGenerator;
           try {
               keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore");
           } catch (NoSuchAlgorithmException | NoSuchProviderException e) {
               throw new RuntimeException("Failed to get KeyGenerator instance", e);
           }


           try {
               keyStore.load(null);
               keyGenerator.init(new
                       KeyGenParameterSpec.Builder(KEY_NAME,
                       KeyProperties.PURPOSE_ENCRYPT |
                               KeyProperties.PURPOSE_DECRYPT)
                       .setBlockModes(KeyProperties.BLOCK_MODE_CBC)
                       .setUserAuthenticationRequired(true)
                       .setEncryptionPaddings(
                               KeyProperties.ENCRYPTION_PADDING_PKCS7)
                       .build());
               keyGenerator.generateKey();
           } catch (NoSuchAlgorithmException |
                   InvalidAlgorithmParameterException
                   | CertificateException | IOException e) {
               throw new RuntimeException(e);
           }
       }

public boolean cipherInit() {
       try {
           cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7);
       } catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
           throw new RuntimeException("Failed to get Cipher", e);
       }


       try {
           keyStore.load(null);
           SecretKey key = (SecretKey) keyStore.getKey(KEY_NAME,
                   null);
           cipher.init(Cipher.ENCRYPT_MODE, key);
           return true;
       } catch (KeyPermanentlyInvalidatedException e) {
           return false;
       } catch (KeyStoreException | CertificateException | UnrecoverableKeyException | IOException | NoSuchAlgorithmException | InvalidKeyException e) {
           throw new RuntimeException("Failed to init Cipher", e);
       }
   }
`