This repository demonstrates how to implement Biometric Authentication in an Android application using Jetpack Compose. It showcases the integration of the BiometricPrompt
API with Compose to provide a modern, user-friendly way to secure access to your app.
Biometric authentication allows users to log in using fingerprint, face, or other biometric data. This example uses the BiometricPrompt
API provided by Android, along with Jetpack Compose for building the UI.
The project includes:
- A Jetpack Compose UI for displaying an authentication button.
- A helper function to handle biometric authentication using
BiometricPrompt
. - Integration that works seamlessly with
FragmentActivity
and Compose.
- Detects if biometric authentication is available on the device.
- Prompts users to authenticate using their biometric credentials.
- Displays the result of authentication (success or failure) in the UI.
- Android Studio Giraffe or later.
- A device or emulator with biometric hardware (e.g., fingerprint scanner or face recognition).
- Minimum SDK level: 23 (Android 6.0).
- Clone this repository:
git clone https://github.com/pranaypatel512/BiometricAuthentication.git
- Open the project in Android Studio.
- Build and run the project on a compatible device or emulator.
- The app checks if biometric authentication is available on the device using the BiometricManager API.
- When the "Authenticate" button is clicked:
- A BiometricPrompt dialog appears.
- Users authenticate using their biometric credentials.
- The authentication result is displayed on the screen.
For a detailed explanation of the implementation, check out the Medium Blog Post (to be published).
- Composable UI: A simple Compose UI for displaying the authentication status.
- BiometricPrompt Integration: A helper function to configure and display the biometric prompt.
- Fragment Compatibility: Ensures compatibility with FragmentActivity for biometric authentication.
- Support it by clicking the ⭐️ button on the upper right of this page. ✌️