Skip to content

A modern, production-grade biometric authentication SDK for Android. Built with Kotlin. Ideal for fintech, banking, secure apps.

Notifications You must be signed in to change notification settings

NonCoderF/biometric-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” Biometric SDK for Android

License

A production-grade biometric authentication SDK designed for apps that demand trust.
Ideal for fintech, banking, e-wallets, secure messaging, parental control, or any app requiring identity protection and transaction-level security.

This SDK simplifies AndroidX biometric integration with modern Kotlin practices, supporting:

  • Fingerprint
  • Face Unlock
  • Device Credential fallback (PIN/Pattern/Password)

Built for real-world apps where authentication reliability is non-negotiable.

πŸš€ Key Features

  • βœ… Seamless integration with AndroidX Biometric APIs
  • βœ… Supports Fingerprint, Face, and Device Credential fallback
  • βœ… Designed for fintech, banking, and high-trust apps
  • βœ… NOT_ENABLED, ENABLED_AND_MANDATORY, ENABLED_BUT_NOT_MANDATORY auth modes
  • βœ… Lifecycle-safe: no biometric prompts while app is backgrounded
  • βœ… Clean Kotlin interfaces β€” easy to test with MockK
  • βœ… Pluggable, SDK-ready structure β€” ideal for JitPack/Maven distribution

πŸ“¦ Installation via JitPack

Use this SDK directly in your Android project using JitPack.


βœ… Step 1: Add JitPack to repositories

In your root-level settings.gradle.kts:

dependencyResolutionManagement { repositories { maven { url = uri("https://jitpack.io") } } }

βœ… Step 2: Add the SDK dependency

In your module-level build.gradle.kts:

implementation("com.github.NoNCoderF:biometric-sdk:v1.0.3")

πŸ§‘β€πŸ’» Usage Guide

This SDK offers two flexible integration modes depending on your product's security needs:


πŸ” Mode 1: Identity Protection Mode (On-Demand Authentication)

Best for apps that want to secure specific features like viewing a profile, accessing settings, or opening sensitive notes.

Biometric is triggered manually when the user takes a high-trust action.

βœ… Example: Trigger Auth Before Showing Profile

private val biometricAuthenticator: BiometricAuthenticator by lazy { val biometricManager = MyBiometricManagerImpl( this, //AppCompatActivity "Unlock", "Unlock to use the app" ) BiometricAuthenticatorImpl( biometricManager, object : BiometricAuthenticatorCallback{ override fun onBiometricSuccess() { //onSuccess } override fun onBiometricFailure(errorCode: Int, errString: CharSequence) { //onFailure } } ) } private val biometricAuthHandler: BiometricAuthHandler by lazy { BiometricAuthHandler( biometricAuthenticator = biometricAuthenticator, requirement = { AuthenticationRequirement.ENABLED_AND_MANDATORY }, bypass = { false }, ) } //On user action // Evaluate biometric flow dynamically fun onClick() { //Reset the prompt controller BiometricPromptController.resetBiometricFlag() when (biometricAuthHandler.evaluate()) { BiometricDecision.BYPASS -> { // Biometric is turned off or bypassed manually } BiometricDecision.SECURITY_NOT_PRESENT -> { // Device doesn't support biometric OR no credential fallback } BiometricDecision.SETUP_REQUIRED -> { // Biometric is supported but user hasn't enrolled β€” suggest settings intent } BiometricDecision.AUTHENTICATE -> { biometricAuthenticator.authenticate() } } } 

πŸ’³ Mode 2: Transaction-Level Security (Automatic Per-Screen Auth)

Use this when your app needs biometric protection for every screen or session, like banking apps, parental control, or work-profile locked apps.

Biometric prompts auto-trigger as the user navigates the app.


βœ… Step 1: Register AppVisibilityTracker (Once)

In your Application or base Activity:

override fun onCreate() { super.onCreate() ProcessLifecycleOwner.get().lifecycle.addObserver(AppVisibilityTracker) }

βœ… Step 2: Create a BaseBiometricActivity

abstract class BaseBiometricActivity : AppCompatActivity() { private val biometricAuthenticator: BiometricAuthenticator by lazy { val biometricManager = MyBiometricManagerImpl( this, //AppCompatActivity "Unlock", "Unlock to use the app" ) BiometricAuthenticatorImpl( biometricManager, object : BiometricAuthenticatorCallback{ override fun onBiometricSuccess() { //onSuccess } override fun onBiometricFailure(errorCode: Int, errString: CharSequence) { //onFailure } } ) } private val biometricAuthHandler: BiometricAuthHandler by lazy { BiometricAuthHandler( biometricAuthenticator = biometricAuthenticator, requirement = { AuthenticationRequirement.ENABLED_AND_MANDATORY }, bypass = { false }, ) } override fun onResume() { super.onResume() // Evaluate biometric flow dynamically when (biometricAuthHandler.evaluate()) { BiometricDecision.BYPASS -> { // Biometric is turned off or bypassed manually } BiometricDecision.PROMPT_SKIPPED -> { // App in foreground, biometric not required in this state } BiometricDecision.SECURITY_NOT_PRESENT -> { // Device doesn't support biometric OR no credential fallback } BiometricDecision.SETUP_REQUIRED -> { // Biometric is supported but user hasn't enrolled β€” suggest settings intent } BiometricDecision.AUTHENTICATE -> { biometricAuthenticator.authenticate() } } } }

Then extend it across your app:

class DashboardActivity : BaseBiometricActivity()

🧭 Use Case Table

Use Case Recommended Mode
Secure a settings/profile page πŸ” Identity Protection (Mode 1)
Authenticate before money transfer πŸ’³ Transaction-Level (Mode 2)
Lock every screen or session πŸ’³ Transaction-Level (Mode 2)

πŸ’‘ Use one mode or both β€” the SDK adapts to your product’s security needs.


πŸ§ͺ Testing

  • πŸ” Built for testability using dependency injection
  • βœ… Easily mock BiometricAuthenticator with MockK
  • 🧼 AppVisibilityTracker is stateless and safe to test

πŸ“œ License

MIT License β€” free for commercial and non-commercial use.
Just give credit where it’s due ❀️


πŸ‘¨β€πŸ’» Author

Built with ❀️ by Nizamuddin Ahmed
Contributions, issues, and stars are always welcome ⭐