A modern, secure Android application demonstrating the implementation of biometric authentication (Fingerprint, Face, Iris) using Jetpack Biometric and Jetpack Compose.
- Standardized Auth: Uses
BiometricPromptfor a consistent system-level experience. - Compose Integration: Seamlessly bridges the
FragmentActivity-based biometric API with a modern Compose UI. - Robust State Handling: Manages authentication lifecycle states:
Idle: Initial state.Success: Authentication confirmed.Failed: Incorrect credential (allows retry).Error: Hardware issues or user cancellation.
- Hardware Validation: Pre-flight checks using
BiometricManagerto verify hardware availability and enrollment.
- Kotlin 2.0+: Primary language with the modern Compose Compiler.
- Jetpack Compose: Declarative UI implementation.
- AndroidX Biometric (1.2.0-alpha05): Standard library for secure authentication.
- Min SDK: 24
- Target SDK: 36
- Architecture: MVVM with
ViewModelandStateFlow.
MainActivity: Inherits fromFragmentActivity(required forBiometricPrompt) and handles the authentication callback.MainViewModel: Encapsulates theAuthStatuslogic, ensuring UI consistency during configuration changes.BiometricAuthScreen: A reactive UI that observes the ViewModel and triggers the system prompt.
- Clone & Open: Open the project in the latest Android Studio.
- Device Setup:
- Use a physical device with a fingerprint or face scanner.
- For Emulators, go to Settings > Security > Fingerprint and register a dummy print (usually by clicking the "..." menu in the emulator and selecting the Fingerprint tab).
- Run: Deploy the
:appmodule.
The app uses BIOMETRIC_STRONG by default, ensuring that only Class 3 (formerly "Strong") biometrics are used, providing a high level of security suitable for sensitive data.