FingerprintAuthHelper

FingerprintAuthHelper

简介:A small library that allows You to easily manage fingererprint authentication inside your Activity or Fragment on devices with fingerprint scanner and Android M and higher.

A small library that allows You to easily manage fingererprint authentication inside your Activity or Fragment on devices with fingerprint scanner and Android M and higher. Min sdk version 14.

  1. Demo app
  2. Usage
  3. Documentation
  4. Callbacks
  5. Updates
  6. Used In
  7. Questions and help
  8. License

alt text alt text

Usage

Add the dependencies to your gradle file:
    dependencies {
        compile 'com.github.pro100svitlo:fingerprintAuthHelper:1.1.5'
    }
Inside your activity or fragment:

    private FingerprintAuthHelper mFAH;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    ...
        mFAH = new FingerprintAuthHelper
                .Builder(this, this) //(Context inscance of Activity, FahListener)
                .build();

        if (mFAH.isHardwareEnable()){
            //do some stuff here
        } else {
            //otherwise do
        }
    }

    ...

   @Override
    protected void onResume() {
        super.onResume();
        mFAH.startListening();
    }

    ...

    @Override
    protected void onPause() {
        super.onPause();
        mFAH.stopListening();
    }

    ...

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mFAH.onDestroy();
    }

That's pretty much all what you need to start the work! Full documentation and all options descriptions you can findhere.


Callbacks:

Your activity or fragment must implement FahListener;

    @Override
    public void onFingerprintStatus(boolean authSuccessful, int errorType, CharSequence errorMess) {
        // authSuccessful - boolean that shows auth status
        // errorType - if auth was failed, you can catch error type
        // errorMess - if auth was failed, errorMess will tell you (and user) the reason

        if (authSuccessful){
            // do some stuff here in case auth was successful
        } else if (mFAH != null){
          // do some stuff here in case auth failed
            switch (errorType){
                case FahErrorType.General.LOCK_SCREEN_DISABLED:
                case FahErrorType.General.NO_FINGERPRINTS:
                    mFAH.showSecuritySettingsDialog();
                    break;
                case FahErrorType.Auth.AUTH_NOT_RECOGNIZED:
                    //do some stuff here
                    break;
                case FahErrorType.Auth.AUTH_TO_MANY_TRIES:
                    //do some stuff here
                    break;
            }
        }
    }

    @Override
    public void onFingerprintListening(boolean listening, long milliseconds) {
        // listening - status of fingerprint listen process
        // milliseconds - timeout value, will be > 0, if listening = false & errorType = AUTH_TO_MANY_TRIES

        if (listening){
            //add some code here
        } else {
            //add some code here
        }
        if (milliseconds > 0) {
            //if u need, u can show timeout for user
        }
    }

Updates

  • v.1.1.5
    1. refactoring
    2. small bugfix
  • v.1.1.4
    1. fix crashes on Sumsung devices
    2. add method isFingerprintEnrolled() to FingerprintAuthHelper
    3. small bugfix
  • v.1.1.3
    1. init context must be instance of Activity
    2. add method showSecuritySettingsDialog() to FingerprintAuthHelper
    3. add help error
  • v.1.1.2
    1. add possibility to set max count of tries
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值