Biometric Authentication in Jetpack Compose Overview This sample project demonstrates how to implement biometric authentication in an Android app using Jetpack Compose. Biometric authentication provides a secure and user-friendly way for users to access sensitive information or perform secure actions within the app.
The example covers the following:
Biometric Prompt Integration: Using the BiometricPrompt API to display a biometric prompt for authentication.
Biometric Authentication UI in Jetpack Compose: Creating a Jetpack Compose UI for biometric authentication that seamlessly integrates with the overall app design.
Handling Biometric Authentication Results: Handling success, failure, and cancellation scenarios when authenticating with biometrics.
Prerequisites Before running the project, ensure that you have:
Android Studio installed (version XYZ or higher). A device or emulator with biometric capabilities (fingerprint, face recognition, etc.). Getting Started
Open the project in Android Studio.
Run the app on your device or emulator.
Usage The app demonstrates biometric authentication through a simple UI. Follow these steps to use the biometric authentication feature:
Launch the app on your device.
Navigate to the section where biometric authentication is required.
The app will prompt you with a biometric authentication dialog (fingerprint or face recognition).
Use the biometric method configured on your device to authenticate.
The app will respond based on the authentication result.
Key Components BiometricAuthViewModel: Manages the authentication logic and interacts with the BiometricPrompt API.
BiometricAuthScreen: Compose UI screen that displays the authentication prompt and handles UI updates based on authentication results.
MainActivity: Entry point of the app and contains the navigation logic.
Dependencies The project uses the following dependencies:
androidx.activity:activity-compose for integrating with the Compose framework in an activity.
androidx.biometric:biometric for working with the BiometricPrompt API.
androidx.compose.foundation:foundation-layout for building the Compose UI layout.
Add other dependencies and versions as needed.
Customization Feel free to customize the app according to your needs. You can modify the UI, enhance security features, or integrate additional biometric authentication methods.
License This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments Special thanks to the Android and Jetpack Compose communities for valuable resources and support. Contributing Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or create a pull request.