我正在编写一个使用本机 Android 指纹 API(在 Android 6.0 及更高版本上)对用户进行身份验证的应用程序。
在一种情况下 - 设备收到 Gcm 通知,并且如果屏幕关闭但手机未锁定 - 应用程序通过启动activity
具有以下标志的“唤醒”设备:
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
然后,该应用程序会显示一个对话框,要求用户使用手指进行身份验证。在这种情况下 - 没有回调函数(来自FingerprintManager.AuthenticationCallback
- )被调用
这是代码:
fingerprintManager.authenticate(null, cancellationSignal, 0, new FingerprintManager.AuthenticationCallback() {
@Override
public void onAuthenticationError(int errorCode, CharSequence errString) {
super.onAuthenticationError(errorCode, errString);
logger.info("Authentication error " + errorCode + " " + errString);
...
}
@Override
public void onAuthenticationHelp(int helpCode, CharSequence helpString) {
super.onAuthenticationHelp(helpCode, helpString);
logger.info("Authentication help message thrown " + helpCode + " " + helpString);
...
}
@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
super.onAuthenticationSucceeded(result);
logger.info("Authentication succeeded");
...
}
/*
* Called when authentication failed but the user can try again
* When called four times - on the next fail onAuthenticationError(FINGERPRINT_ERROR_LOCKOUT)
* will be called
*/
@Override
public void onAuthenticationFailed() {
super.onAuthenticationFailed();
logger.info("Authentication failed");
...
}
}, null);
当屏幕打开和关闭时运行相同的代码,但当它关闭并由活动打开时 - 不会调用回调。
有任何想法吗?提前致谢!