1

I am trying to integrate BiometricPrompt with Jetpackcompose

Here is a snippet of my code which is called on a button click

val context = LocalContext.current
val biometricPrompt =BiometricPrompt(context as FragmentActivity,ContextCompat.getMainExecutor(context),object : BiometricPrompt.AuthenticationCallback() {.....

The error is context as FragmentActivity, not sure how to and what to cast the context as. I tried Activity, ComponentActivity as well.

As soon as i click the button i get error saying

java.lang.ClassCastException: com.compose.MainActivity cannot be cast to androidx.fragment.app.FragmentActivity

I tried looking in to this as well but it does not work

Go Fudge YourSelves
  • 139
  • 1
  • 2
  • 10

1 Answers1

2

According to the doc, BiometricPrompt requires a FragmentActivity.

enter image description here

Check your MainActivity class.
It should extend AppCompatActivity or FragmentActivity instead of ComponentActivity.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841