5

I'm trying to implement the fingerprint authentication in my android app.
I'm using this library: https://github.com/infinum/Android-Goldfinger which uses BiometricPrompt and it works really good. The issue is that I need to use it in an activity that shows up on the lock screen. In particular the activity is using these flags:

window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD)
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED)
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)

When the activity is started normally (not on the lock screen), the fingerprint authentication dialog pops up and works good. Instead when the activity is showed on lock screen the fingerprint authentication dialog doesn't show up.

I've read about the FingerprintManager that uses the old (and deprecated) APIs, which I'd like not to use.

Is there a way to apply those flags also on the BiometricPrompt dialog? or it is not permitted at all to show dialogs on lock screen?

Ajeett
  • 814
  • 2
  • 7
  • 18
Francesco Re
  • 836
  • 6
  • 22
  • Not to sure if I understand this correctly. You can launch activity but not dialog because you can't set the flags on dialog ? Also take a look at Biometric lib from jetpack. There's a biometric manager, possibly you could implement you're own prompt on activity. `https://developer.android.com/jetpack/androidx/releases/biometric` – Sylwek845 Feb 08 '20 at 14:55
  • @Sylwek Yeah, the activity is visible on the lock screen but the dialog is not showed. Even using the BiometricPrompt directly (bypassing the library) it is the same thing. Instead, if I show an AlertDialog on the lock screen, it is showed. – Francesco Re Feb 08 '20 at 16:44
  • I can't find any proof of this information, but I remember when I was implementing biometric I saw somewhere (documentation/guide how to etc.), that you won't receive callbacks from biometric manager or create crypto key or something like that, when device is locked. So firstly you have to unlock device. My advice to you - don't use library for that, implement yourself, you will have more flexibility – Ruslan Myhal Feb 11 '20 at 10:42
  • @RuslanMyhal Well, that was my fear. I will try other implementations just to find out if this is really impossible to make. Thank you – Francesco Re Feb 11 '20 at 21:44
  • @FrancescoRe in your onAuthenticationError, add something like if (++attempts == 1 && errorCode == 5) biometricPrompt.authenticate(...). it flashes, but it works – HelloWorld Jul 10 '22 at 18:42

0 Answers0