Search code examples
kotlinandroid-jetpack-composeandroid-biometric-prompt

BiometricPrompt with Jetpack Compose


BiometricPrompt requires either Fragment or FragmentActivity in its constructor. I cannot find out how to use BiometricPrompt from a Composable screen, not in the documentation, not in any tutorial. Has anyone in here dealt with the same problem? Or is there any other way to use biometric authentication in a fully Compose built application?


Solution

  • Subclass your MainActivity from FragmentActivity, then in composable get your context:

    val context = LocalContext.current as FragmentActivity
    

    Check out some examples on github: https://github.com/search?l=kotlin&q=BiometricPrompt%20composable&type=Code