Git Product home page Git Product logo

android_fingerprint_authentication_library's Introduction

Fingerprint Authentication Library

This project provides a fingerprint authentication library for use in Android applications.

Overview

This library is designed to easily integrate biometric authentication functionality into your Android apps. It offers a simple API to implement the fingerprint authentication process.

How to Use

Initialization

val authenticator: Authenticator = AuthenticatorFactory.create()
authenticator.initialize(this) // 'this' refers to an instance of AppCompatActivity.

Check Authentication Capability

if (authenticator.canAuthenticate()) {
    // In case authentication is possible
} else {
    // In case authentication is not possible
}

Execute Authentication

authenticator.authenticate()

Observe Authentication State

authenticator.getLoginState().collect { state ->
    when (state) {
        is AuthState.Idle -> // Initial state
        is AuthState.Error -> // Authentication error
        is AuthState.Fail -> // Authentication failure
        is AuthState.Success -> // Authentication success
    }
}

Customization and Contribution

You are free to modify and extend this library to suit your needs. If you have any changes or improvements, please send a Pull Request. Also, if you find this project helpful, please give it a Star to show your support!

Usage Example

Here is a simple example of using this library:

In XML

class MyActivity : AppCompatActivity() {

    private lateinit var authenticator: Authenticator

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_my)

        authenticator = AuthenticatorFactory.create()
        authenticator.initialize(this)

        if (authenticator.canAuthenticate()) {
            authenticator.authenticate()
        }

        lifecycleScope.launchWhenStarted {
            authenticator.getLoginState().collect { state ->
                // Update UI based on state
            }
        }
    }
}

In Jetpack Compose

@Composable
fun Example(context: AppCompatActivity){
    val authenticator: Authenticator = remember { AuthenticatorFactory.create() }
    val isLogin = authenticator.getLoginState().collectAsState()
    val canAuthenticate = remember { mutableStateOf(false) }
    LaunchedEffect(Unit) {
        authenticator.initialize(context)
        canAuthenticate.value = authenticator.canAuthenticate()
    }
    when (isLogin.value) {
        AuthState.Success -> Text(text = "Login Success!!")
        AuthState.Fail -> Text(text = "Fail!")
        AuthState.Error -> Text(text = "Error!")
        AuthState.Idle -> {}
    }
    Button(onClick = { authenticator.authenticate() }) {
        Text(text = "login with fingerprint")
    }
}

android_fingerprint_authentication_library's People

Contributors

gunchimssak avatar lyh990517 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.