为什么是FingerprintManager ?前台服务中AuthenticationCallback没有响应?<



为什么是FingerprintManager ?前台服务中AuthenticationCallback没有响应?

//Inside onStartCommand method
WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
windowManager.addView(view, layoutParams);
startForeground(NotificationControl.notificationId, NotificationControl.builderOfNotification(this, false).build());
FingerprintManager fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
FingerprintManager.AuthenticationCallback authenticationCallback = new FingerprintManager.AuthenticationCallback() {
@Override
public void onAuthenticationError(int errorCode, CharSequence errString) {
super.onAuthenticationError(errorCode, errString);
Toast.makeText(ForegroundService.this, "1", Toast.LENGTH_SHORT).show();
}
@Override
public void onAuthenticationHelp(int helpCode, CharSequence helpString) {
super.onAuthenticationHelp(helpCode, helpString);
Toast.makeText(ForegroundService.this, "2", Toast.LENGTH_SHORT).show();
}
@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
super.onAuthenticationSucceeded(result);
Toast.makeText(ForegroundService.this, "3", Toast.LENGTH_SHORT).show();
}
@Override
public void onAuthenticationFailed() {
super.onAuthenticationFailed();
Toast.makeText(ForegroundService.this, "4", Toast.LENGTH_SHORT).show();
}
};
fingerprintManager.authenticate(null, null, 0, authenticationCallback, null);

如果活动正在运行,它工作得很好,但是如果我破坏活动,上面的监听器没有响应,为什么?

最后,经过几个小时的尝试,我发现了这个问题,解决方案是你必须创建AccessibilityService并从设置中启用权限,启用权限后,Callback将工作。

相关内容

  • 没有找到相关文章

最新更新