lopspower / Biometric

The easiest way is to use the new version of Biometric under AndroidX 🔒
Apache License 2.0
140 stars 16 forks source link

How can I use it in an Activity #1

Closed woxingxiao closed 4 years ago

woxingxiao commented 4 years ago

Thanks for your excellent work for this lib. 👍👍

But why the BiometricHelper has to be instanced in a fragment? How can I use it in an activity?

class BiometricHelper(private val fragment: Fragment) 

Isn't this a better way?

class BiometricHelper(private val context: Context) 
lopspower commented 4 years ago

Hello, Sorry this is not possible due to the implementation of Google of BiometricPrompt. You absolutely need a Fragment or a FragmentActivity: https://developer.android.com/reference/androidx/biometric/BiometricPrompt#BiometricPrompt(androidx.fragment.app.FragmentActivity,%20java.util.concurrent.Executor,%20androidx.biometric.BiometricPrompt.AuthenticationCallback)