Coder Social home page Coder Social logo

newman-chen / biometricpromptcompat Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fython/biometricpromptcompat

0.0 0.0 0.0 305 KB

Make BiometricPrompt (Android P feature) support all Android 6.0+ devices.

License: Apache License 2.0

Java 100.00%

biometricpromptcompat's Introduction

BiometricPromptCompat

In Android P, Google provides a easier way for developers to use biometric sensors to authenticate user identity: BiometricPrompt. However, it is only supported in latest Android. We create a compat library to take it to All Android 6.0+ devices.

My introduction in Chinese (中文介绍)

Introduction

What is BiometricPrompt?

It looks like mostly a new FingerprintManager which is added in Android 6.0 (M). Its literal meaning may be: not only fingerprints will be supported, but also other biometric sensors.

So if we use this API, it's easy to support other biometric sensors for authenticating, such as face identity.

To learn more, read BiometricPrompt Reference in Android Developers site.

How to use it in old devices?

BiometricPromptCompat is designed to make it compatible in old Android. Its interface is very close to the original BiometricPrompt in order that we can keep a consistent UI in different Android.

Of course, in Android P or newer version, we will use original BiometricPrompt API. Then we cannot guarantee the UI is completely consistent in different devices. Because ROM manufacturers will redesign in their own styles.

And we should realize that in Android M there is only fingerprint sensor to be supported. I am sorry that I have no plan to adapt thousands of ROMs' incompatible APIs.

Requirements

  • Platform SDK for Android P Preview (android-p)
  • Android Studio 3.1+

Samples

Download

Include library in your app module:

dependencies {
     implementation 'moe.feng.support.biometricprompt:library:1.0.1'
}

We recommend to learn FingerprintManager or BiometricPrompt before using this library. All you need to know will be found.

final BiometricPromptCompat biometricPrompt = new BiometricPromptCompat.Builder(context)
        .setTitle("Title")
        .setSubtitle("Subtitle")
        .setDescription("Description: blablablablablablablablablablabla...")
        .setNegativeButton("Use password", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Toast.makeText(
                    context,
                    "You requested password.",
                    Toast.LENGTH_LONG).show();
            }
        })
        .build();

biometricPrompt.authenticate(cancellationSignal, myCallback);

Test & Screenshots

Tested successfully in Android 8.1 & P Preview.

Android 8.1

Android P Preview

Contact author

Telegram: @fython

License

Apache License 2.0

biometricpromptcompat's People

Contributors

fython avatar siczmj avatar yuriiostrovskyi avatar tougee 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.