3

I have functionality in my application in which I am showing the overlay screen and I want to add fingerprint in that view, I tried adding but getting below error,

/system_process W/FingerprintService: Rejecting com.package.myapp ; not in foreground
01576-1576/system_process V/FingerprintService: authenticate(): reject com.package.myapp

But If I integrate it in activity it is working fine.

How can I add fingerprint auth on overlay from service?

Please give solution over this

Amin Pinjari
  • 2,129
  • 3
  • 25
  • 53

1 Answers1

0

If you look into the source code for FingerPrintService you will see that when you call FingerprintManager#authenticate it then calls into #canUseFingerprint which requires that you are running this in a foreground Activity. So using FingerprintManager will require to have your overlay screen either get the Activity reference that launched your overlay, or launch an Activity that runs the fingerprint sensor.

Also note that FingerprintManager has been deprecated and replaced by BiometricPrompt. Here is a helpful Medium article that walks you through a BiometricPrompt implementation. However, note that it too requires an Activity context for determining when the Activity has gone to the background, then the biometric prompt gets dismissed automatically.

Jason Grife
  • 1,197
  • 11
  • 14
  • I am launching overlay from service, is there any way to use fingerprint in this case.? – Amin Pinjari Sep 11 '19 at 06:28
  • Are you using an activity to start the service, which is launching the overlay? If so, use that activity to first launch the fingerprint prompt and once the user has completed that, then start your service. If not, would this work for you? – Jason Grife Sep 11 '19 at 07:34
  • 1
    my app is similar to applock, I am launching overlay from service How can I pass Activity context from service? – Amin Pinjari Sep 11 '19 at 15:27
  • I'm not familiar with applock, but I think your choices are to either use the activity, that starts your service, first launch the fingerprint prompt. Or, have your service start an activity that then launches the fingerprint prompt. – Jason Grife Sep 11 '19 at 16:26
  • @AminPinjari Did you find the solution? – WonderSoftwares Sep 10 '20 at 12:04
  • for fingerprint i used activity only. nothing else worked – Amin Pinjari Nov 12 '20 at 13:44
  • I am creating an app lock, I use one foreground service and using biometric authentication in this and it works fine if the app is in the foreground, but it does not work if the app is in the background or killed, I always get an error callback. if it does not work in background, then there is one app on play store that uses fingerprint authentication in service even when app is in background or kiled. https://play.google.com/store/apps/details?id=com.ultra.applock – Shubham Mogarkar Apr 11 '23 at 07:10