Skip to content
Biometricks - Tricks for Android Biometrics
Kotlin
Branch: master
Clone or download

README.md

Biometricks - Tricks for Android Biometrics

CURRENTLY IN DEVELOPMENT

Provides various hacks/tricks to help work with the AndroidX Biometric APIs.

Features:

  • The ability to detect the type of Biometric the device supports for better user messaging.
  • Ability to detect the need to show a loading dialog for API 28.
  • 100% Kotlin API, no Java support is planned.
Fingerprint Face

Why?

The AndroidX Biometric Library doesn't tell you what type of Biometric feature the device has and will be used. This library figures that out for you so you can create better user messaging than just "Biometric" in most cases.

Usage

val biometricks = Biometricks.from(applicationContext)

val biometricName = when (biometricks) {
    Face -> "Face"
    Fingerprint -> "Fingerprint"
    Iris -> "Iris"
    Unknown,
    Multiple -> "Biometric"
}

CryptoObject Required

In order to correctly have the UI show the detected biometric type, we encourage you to use our helper functions. It will require you to pass a BiometricPrompt.CryptoObject.

Biometricks.showPrompt(
    activity,
    BiometricPromptInfo(
        title = "Authenticate with $biometricName",
        negativeButtonText = "Cancel",
        cryptoObject = cryptoObject
    )
) { showLoading ->
    // Show a loading view for API 28 issues if you want
}

NOTE: This type is only valid when you show a BiometricPrompt and send in a CryptoObject.

The Types of Biometricks (Source)

sealed class Biometricks {

    /** The device has no support for Biometric Authentication */
    object None : Biometricks()

    /** The device has support for Biometric Authentication */
    sealed class Available : Biometricks() {
        object Face : Available()
        object Fingerprint : Available()
        object Iris : Available()
        object Multiple : Available()
        object Unknown : Available()
    }
}

Related Content

Contributors

You can’t perform that action at this time.