Skip to content
프로젝트

소개

지문 인식을 RxJava로 간단히 래핑하고 라이프사이클에 자동으로 바인딩합니다. 지문 인식 UI 컴포넌트도 구현했습니다.

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

RxFingerPrinter

Build Status

用rxjava封装了指纹识别,并实现对生命周期的自动绑定,顺便撸了一个指纹控件。

image

Setup

测试机型推荐android版本6.0以上且具有指纹模块

在项目build.gradle中配置 :

repositories {
    jcenter() // If not already there
}

在Module中build.gradle中配置 :

Download

dependencies {
    compile  'com.zwh:RxFingerPrinter:1.2.1'
}

Usage

创建一个 RxFingerPrinter实例 :

RxFingerPrinter rxFingerPrinter = new RxFingerPrinter(this); // where this is an Activity instance

在需要开启指纹识别的地方执行begin方法并订阅:

// 可以在oncreat方法中执行
DisposableObserver<IdentificationInfo> observer =
                        new DisposableObserver<IdentificationInfo>() {
                    @Override
                    protected void onStart() {
                        
                    }

                    @Override
                    public void onError(Throwable e) {
                    
                    }

                    @Override
                    public void onComplete() {

                    }

                    @Override
                    public void onNext(IdentificationInfo info) {
                        if(info.isSuccessful()){//识别成功
                            Toast.makeText(MainActivity.this, "指纹识别成功", Toast.LENGTH_SHORT).show();
                        }else{//识别失败 获取错误信息
                             FPerException exception = info.getException();
                             if (exception != null){
                                Toast.makeText(MainActivity.this,exception.getDisplayMessage(),Toast.LENGTH_SHORT).show();
                             }
                        }
                    }
                };
                rxfingerPrinter.begin().subscribe(observer);//RxfingerPrinter会自动在onPause()时暂停指纹监听,onResume()时恢复指纹监听)

用FPerException封装了一下指纹识别时可能出现的异常,可以在订阅的Subscriber的onNext(IdentificationInfo info)中的IdentificationInfo获取该异常

@Override
public void onNext(IdentificationInfo info) {
    FPerException exception = info.getException();
    if (exception != null){
        Toast.makeText(MainActivity.this,exception.getDisplayMessage(),Toast.LENGTH_SHORT).show();
    }
}

可以根据FPerException.getCode() 来获取对应的错误码,也可以直接调用FPerException.getDisplayMessage()提示默认的错误信息。

public String getDisplayMessage() {
        switch (code) {
            case SYSTEM_API_ERROR:
                return "系统API小于23";
            case PERMISSION_DENIED_ERROE:
                return "没有指纹识别权限";
            case HARDWARE_MISSIING_ERROR:
                return "没有指纹识别模块";
            case KEYGUARDSECURE_MISSIING_ERROR:
                return "没有开启锁屏密码";
            case NO_FINGERPRINTERS_ENROOLED_ERROR:
                return "没有指纹录入";
            case FINGERPRINTERS_FAILED_ERROR:
                return "指纹认证失败,请稍后再试";
            case FINGERPRINTERS_RECOGNIZE_FAILED:
                return "指纹识别失败,请重试";
            default:
                return "";
        }
    }

License

 Copyright 2018, Zweihui 
  
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at 
 
       http://www.apache.org/licenses/LICENSE-2.0 

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

관련 프로젝트 살펴보기

불러오는 중…