BiometricAndroid

The one wiring hook Android needs: BiometricPrompt hosts itself in a FragmentActivity, and a library module has no way to reach one on its own.

Install a provider, not an activity. The provider is asked for the currently resumed activity at the moment a prompt is shown, so nothing here outlives a rotation:

// Application.onCreate(), alongside registerActivityLifecycleCallbacks:
BiometricAndroid.install { currentResumedActivity as? FragmentActivity }

A lambda that captures one activity instance directly will leak it for the process lifetime — return the current one from a holder your app already keeps, or clear it with install(null) when that activity is destroyed.

Until a provider is installed (or while it returns null), BiometricAuthenticator.canAuthenticate reports BiometricAvailability.NotConfigured — an answer with a reason, not a dead button.

Functions

Link copied to clipboard
fun install(provider: () -> FragmentActivity??)

Installs (or, with null, removes) the current-activity provider.