kotlinandroid-jetpack-composeandroid-biometric-prompt

BiometricPrompt Jetpack Compose


I would like to use biometric authentication on my application.

To do this in my view I declare a val context = LocalContext.current as its value and then I cast it to FragmentActivity. But it crashes all the time with the following error: com.example.MainActivity cannot be cast to androidx.fragment.app.FragmentActivity, and I can't find another method to find a FragmentActivty from a Composable View for BiometricPrompt.

Thanks for your help!


Solution

  • Looks like your com.example.MainActivity is not subclass of FragmentActivity

    It should be like class MainActivity : FragmentActivity() { ... }